summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2017-02-24 13:52:07 +0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-24 01:10:22 -0800
commit1e2580c3fd73d5b1ca06ecc870f38c43dfc4abe8 (patch)
tree393fe706bb12c962915726ee624fdf1718e48789 /tests
parent5b8bde8e1e97ea597c28e52e88fbc9475e6ea294 (diff)
downloadsubsurface-1e2580c3fd73d5b1ca06ecc870f38c43dfc4abe8.tar.gz
Use SUBSURFACE_TEST_DATA definition to point to test data dir
Update tests with a (compile time) option SUBSURFACE_TEST_DATA, pointing to test data base path. It is needed for cross compilation cases. SUBSURFACE_TEST_DATA is set to SUBSURFACE_SOURCE by default, or configurable via cmake option -DSUBSURFACE_TEST_DATA="...". Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt8
-rw-r--r--tests/testdivesiteduplication.cpp2
-rw-r--r--tests/testgitstorage.cpp14
-rw-r--r--tests/testmerge.cpp12
-rw-r--r--tests/testparse.cpp34
-rw-r--r--tests/testpicture.cpp4
-rw-r--r--tests/testrenumber.cpp6
7 files changed, 44 insertions, 36 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 1aab4ab1c..14116449d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,6 +1,13 @@
# QTest based tests
qt5_add_resources(SUBSURFACE_TEST_RESOURCES ../subsurface.qrc)
+# Access test data (dive folder) from SUBSURFACE_SOURCE by default.
+# In cross compilation cases or when test will not be executed at build time
+# a differnt value can be set via cmake -DSUBSURFACE_TEST_DATA.
+if(NOT SUBSURFACE_TEST_DATA)
+ set(SUBSURFACE_TEST_DATA ${SUBSURFACE_SOURCE})
+endif()
+
add_library(RESOURCE_LIBRARY STATIC ${SUBSURFACE_TEST_RESOURCES})
macro(TEST NAME FILE)
@@ -11,6 +18,7 @@ endmacro()
enable_testing()
add_definitions(-g)
+add_definitions(-DSUBSURFACE_TEST_DATA="${SUBSURFACE_TEST_DATA}")
TEST(TestUnitConversion testunitconversion.cpp)
TEST(TestProfile testprofile.cpp)
TEST(TestGpsCoords testgpscoords.cpp)
diff --git a/tests/testdivesiteduplication.cpp b/tests/testdivesiteduplication.cpp
index 803f3f187..9a47d1ce9 100644
--- a/tests/testdivesiteduplication.cpp
+++ b/tests/testdivesiteduplication.cpp
@@ -4,7 +4,7 @@
void TestDiveSiteDuplication::testReadV2()
{
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/TwoTimesTwo.ssrf"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TwoTimesTwo.ssrf"), 0);
QCOMPARE(dive_site_table.nr, 2);
}
diff --git a/tests/testgitstorage.cpp b/tests/testgitstorage.cpp
index 038209534..8d7558f7c 100644
--- a/tests/testgitstorage.cpp
+++ b/tests/testgitstorage.cpp
@@ -64,7 +64,7 @@ void TestGitStorage::testGitStorageLocal()
// test writing and reading back from local git storage
git_repository *repo;
git_libgit2_init();
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/SampleDivesV2.ssrf"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0);
QString testDirName("./gittest");
QDir testDir(testDirName);
QCOMPARE(testDir.removeRecursively(), true);
@@ -93,7 +93,7 @@ void TestGitStorage::testGitStorageCloud()
// connect to the ssrftest repository on the cloud server
// and repeat the same test as before with the local git storage
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/SampleDivesV2.ssrf"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0);
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
clear_dive_file_data();
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
@@ -119,7 +119,7 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
// read the local repo from the previous test and add dive 10
QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0);
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test10.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml"), 0);
// calling process_dive() sorts the table, but calling it with
// is_imported == true causes it to try to update the window title... let's not do that
process_dives(false, false);
@@ -169,14 +169,14 @@ void TestGitStorage::testGitStorageCloudMerge()
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
QString localCacheRepoSave = localCacheDir + "save[ssrftest@hohndel.org]";
QCOMPARE(parse_file(qPrintable(localCacheRepoSave)), 0);
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test11.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0);
process_dives(false, false);
QCOMPARE(save_dives(qPrintable(localCacheRepoSave)), 0);
clear_dive_file_data();
// now we open the cloud storage repo and add a different dive to it
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test12.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0);
process_dives(false, false);
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
clear_dive_file_data();
@@ -191,9 +191,9 @@ void TestGitStorage::testGitStorageCloudMerge()
QCOMPARE(save_dives("./SapleDivesV3plus10-11-12-merged.ssrf"), 0);
clear_dive_file_data();
QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf"), 0);
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test11.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0);
process_dives(false, false);
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test12.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0);
process_dives(false, false);
QCOMPARE(save_dives("./SapleDivesV3plus10-11-12.ssrf"), 0);
QFile org("./SapleDivesV3plus10-11-12-merged.ssrf");
diff --git a/tests/testmerge.cpp b/tests/testmerge.cpp
index 05c88a88e..6661880d1 100644
--- a/tests/testmerge.cpp
+++ b/tests/testmerge.cpp
@@ -15,12 +15,12 @@ void TestMerge::testMergeEmpty()
/*
* check that we correctly merge mixed cylinder dives
*/
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml"), 0);
process_dives(true, false);
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test48.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml"), 0);
process_dives(true, false);
QCOMPARE(save_dives("./testmerge47+48.ssrf"), 0);
- QFile org(SUBSURFACE_SOURCE "/dives/test47+48.xml");
+ QFile org(SUBSURFACE_TEST_DATA "/dives/test47+48.xml");
org.open(QFile::ReadOnly);
QFile out("./testmerge47+48.ssrf");
out.open(QFile::ReadOnly);
@@ -39,12 +39,12 @@ void TestMerge::testMergeBackwards()
/*
* check that we correctly merge mixed cylinder dives
*/
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test48.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml"), 0);
process_dives(true, false);
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml"), 0);
process_dives(true, false);
QCOMPARE(save_dives("./testmerge47+48.ssrf"), 0);
- QFile org(SUBSURFACE_SOURCE "/dives/test47+48.xml");
+ QFile org(SUBSURFACE_TEST_DATA "/dives/test47+48.xml");
org.open(QFile::ReadOnly);
QFile out("./testmerge47+48.ssrf");
out.open(QFile::ReadOnly);
diff --git a/tests/testparse.cpp b/tests/testparse.cpp
index b0baab403..a42a53fc8 100644
--- a/tests/testparse.cpp
+++ b/tests/testparse.cpp
@@ -80,7 +80,7 @@ void TestParse::testParseCSV()
params[pnr++] = intdup(-1);
params[pnr++] = NULL;
- QCOMPARE(parse_manual_file(SUBSURFACE_SOURCE "/dives/test41.csv", params, pnr - 1), 0);
+ QCOMPARE(parse_manual_file(SUBSURFACE_TEST_DATA "/dives/test41.csv", params, pnr - 1), 0);
fprintf(stderr, "number of dives %d \n", dive_table.nr);
}
@@ -92,7 +92,7 @@ void TestParse::testParseDivingLog()
struct dive_site *ds = alloc_or_get_dive_site(0xdeadbeef);
ds->name = copy_string("Suomi - - Hälvälä");
- QCOMPARE(sqlite3_open(SUBSURFACE_SOURCE "/dives/TestDivingLog4.1.1.sql", &handle), 0);
+ QCOMPARE(sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDivingLog4.1.1.sql", &handle), 0);
QCOMPARE(parse_divinglog_buffer(handle, 0, 0, 0, &dive_table), 0);
sqlite3_close(handle);
@@ -101,19 +101,19 @@ void TestParse::testParseDivingLog()
void TestParse::testParseV2NoQuestion()
{
// parsing of a V2 file should work
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test40.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml"), 0);
}
void TestParse::testParseV3()
{
// parsing of a V3 files should succeed
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test42.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test42.xml"), 0);
}
void TestParse::testParseCompareOutput()
{
QCOMPARE(save_dives("./testout.ssrf"), 0);
- QFile org(SUBSURFACE_SOURCE "/dives/test40-42.xml");
+ QFile org(SUBSURFACE_TEST_DATA "/dives/test40-42.xml");
org.open(QFile::ReadOnly);
QFile out("./testout.ssrf");
out.open(QFile::ReadOnly);
@@ -131,7 +131,7 @@ void TestParse::testParseDM4()
{
sqlite3 *handle;
- QCOMPARE(sqlite3_open(SUBSURFACE_SOURCE "/dives/TestDiveDM4.db", &handle), 0);
+ QCOMPARE(sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDiveDM4.db", &handle), 0);
QCOMPARE(parse_dm4_buffer(handle, 0, 0, 0, &dive_table), 0);
sqlite3_close(handle);
@@ -140,7 +140,7 @@ void TestParse::testParseDM4()
void TestParse::testParseCompareDM4Output()
{
QCOMPARE(save_dives("./testdm4out.ssrf"), 0);
- QFile org(SUBSURFACE_SOURCE "/dives/TestDiveDM4.xml");
+ QFile org(SUBSURFACE_TEST_DATA "/dives/TestDiveDM4.xml");
org.open(QFile::ReadOnly);
QFile out("./testdm4out.ssrf");
out.open(QFile::ReadOnly);
@@ -193,7 +193,7 @@ void TestParse::testParseHUDC()
params[pnr++] = strdup("\"DC text\"");
params[pnr++] = NULL;
- QCOMPARE(parse_csv_file(SUBSURFACE_SOURCE "/dives/TestDiveSeabearHUDC.csv",
+ QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearHUDC.csv",
params, pnr - 1, "csv"), 0);
QCOMPARE(dive_table.nr, 1);
@@ -212,7 +212,7 @@ void TestParse::testParseHUDC()
void TestParse::testParseCompareHUDCOutput()
{
QCOMPARE(save_dives("./testhudcout.ssrf"), 0);
- QFile org(SUBSURFACE_SOURCE "/dives/TestDiveSeabearHUDC.xml");
+ QFile org(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearHUDC.xml");
org.open(QFile::ReadOnly);
QFile out("./testhudcout.ssrf");
out.open(QFile::ReadOnly);
@@ -240,7 +240,7 @@ void TestParse::testParseNewFormat()
* Set the directory location and file filter for H3 CSV files.
*/
- dir = QString::fromLatin1(SUBSURFACE_SOURCE "/dives");
+ dir = QString::fromLatin1(SUBSURFACE_TEST_DATA "/dives");
filter << "TestDiveSeabearH3*.csv";
filter << "TestDiveSeabearT1*.csv";
files = dir.entryList(filter, QDir::Files);
@@ -253,7 +253,7 @@ void TestParse::testParseNewFormat()
QString delta;
QStringList currColumns;
QStringList headers;
- QString file = QString::fromLatin1(SUBSURFACE_SOURCE "/dives/").append(files.at(i));
+ QString file = QString::fromLatin1(SUBSURFACE_TEST_DATA "/dives/").append(files.at(i));
QFile f(file);
/*
@@ -368,7 +368,7 @@ void TestParse::testParseNewFormat()
void TestParse::testParseCompareNewFormatOutput()
{
QCOMPARE(save_dives("./testsbnewout.ssrf"), 0);
- QFile org(SUBSURFACE_SOURCE "/dives/TestDiveSeabearNewFormat.xml");
+ QFile org(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearNewFormat.xml");
org.open(QFile::ReadOnly);
QFile out("./testsbnewout.ssrf");
out.open(QFile::ReadOnly);
@@ -388,7 +388,7 @@ void TestParse::testParseCompareNewFormatOutput()
void TestParse::testParseDLD()
{
struct memblock mem;
- QString filename = SUBSURFACE_SOURCE "/dives/TestDiveDivelogsDE.DLD";
+ QString filename = SUBSURFACE_TEST_DATA "/dives/TestDiveDivelogsDE.DLD";
QVERIFY(readfile(filename.toLatin1().data(), &mem) > 0);
QVERIFY(try_to_open_zip(filename.toLatin1().data()) > 0);
@@ -405,7 +405,7 @@ void TestParse::testParseCompareDLDOutput()
*/
QCOMPARE(save_dives("./testdldout.ssrf"), 0);
- QFile org(SUBSURFACE_SOURCE "/dives/TestDiveDivelogsDE.xml");
+ QFile org(SUBSURFACE_TEST_DATA "/dives/TestDiveDivelogsDE.xml");
org.open(QFile::ReadOnly);
QFile out("./testdldout.ssrf");
out.open(QFile::ReadOnly);
@@ -424,10 +424,10 @@ void TestParse::testParseMerge()
/*
* check that we correctly merge mixed cylinder dives
*/
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/ostc.xml"), 0);
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/vyper.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/ostc.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/vyper.xml"), 0);
QCOMPARE(save_dives("./testmerge.ssrf"), 0);
- QFile org(SUBSURFACE_SOURCE "/dives/mergedVyperOstc.xml");
+ QFile org(SUBSURFACE_TEST_DATA "/dives/mergedVyperOstc.xml");
org.open(QFile::ReadOnly);
QFile out("./testmerge.ssrf");
out.open(QFile::ReadOnly);
diff --git a/tests/testpicture.cpp b/tests/testpicture.cpp
index 6b59018c1..e3565df9d 100644
--- a/tests/testpicture.cpp
+++ b/tests/testpicture.cpp
@@ -17,14 +17,14 @@ void TestPicture::addPicture()
struct picture *pic;
verbose = 1;
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test44.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test44.xml"), 0);
dive = get_dive(0);
QVERIFY(dive != NULL);
pic = dive->picture_list;
// So far no picture in dive
QVERIFY(pic == NULL);
- dive_create_picture(dive, SUBSURFACE_SOURCE "/wreck.jpg", 0, false);
+ dive_create_picture(dive, SUBSURFACE_TEST_DATA "/wreck.jpg", 0, false);
pic = dive->picture_list;
// Now there is a picture
QVERIFY(pic != NULL);
diff --git a/tests/testrenumber.cpp b/tests/testrenumber.cpp
index e7cbbfac6..0f694102f 100644
--- a/tests/testrenumber.cpp
+++ b/tests/testrenumber.cpp
@@ -6,14 +6,14 @@
void TestRenumber::setup()
{
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml"), 0);
process_dives(false, false);
dive_table.preexisting = dive_table.nr;
}
void TestRenumber::testMerge()
{
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47b.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47b.xml"), 0);
process_dives(true, false);
QCOMPARE(dive_table.nr, 1);
QCOMPARE(unsaved_changes(), 1);
@@ -23,7 +23,7 @@ void TestRenumber::testMerge()
void TestRenumber::testMergeAndAppend()
{
- QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47c.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47c.xml"), 0);
process_dives(true, false);
QCOMPARE(dive_table.nr, 2);
QCOMPARE(unsaved_changes(), 1);