summaryrefslogtreecommitdiffstats
path: root/hl/test/CMakeTests.cmake
blob: 4e945bce88795f943fd10c360484788cc09208f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#
# Copyright by The HDF Group.
# All rights reserved.
#
# This file is part of HDF5.  The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#

##############################################################################
##############################################################################
###           T E S T I N G                                                ###
##############################################################################
##############################################################################

set (HL_REFERENCE_TEST_FILES
    dtype_file.txt
    image8.txt
    sepia.pal
    earth.pal
    image24pixel.txt
    image24plane.txt
    usa.wri
    test_table_be.h5
    test_table_cray.h5
    test_table_le.h5
    dsdata.txt
    dslat.txt
    dslon.txt
    test_ds_be.h5
    test_ds_le.h5
    test_ld.h5
)

# --------------------------------------------------------------------
#-- Copy the necessary files.
# --------------------------------------------------------------------
foreach (h5_file ${HL_REFERENCE_TEST_FILES})
  HDFTEST_COPY_FILE("${HDF5_HL_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_HL_TEST_BINARY_DIR}/${h5_file}" "hl_test_files")
endforeach ()
add_custom_target(hl_test_files ALL COMMENT "Copying files needed by hl_test tests" DEPENDS ${hl_test_files_list})

# --------------------------------------------------------------------
#  Macro used to add a unit test
# --------------------------------------------------------------------
macro (HL_ADD_TEST hl_name)
  if (HDF5_ENABLE_USING_MEMCHECKER)
    add_test (NAME HL_${hl_name} COMMAND $<TARGET_FILE:hl_${hl_name}>)
  else ()
    add_test (NAME HL_${hl_name} COMMAND "${CMAKE_COMMAND}"
        -D "TEST_PROGRAM=$<TARGET_FILE:hl_${hl_name}>"
        -D "TEST_ARGS:STRING="
        -D "TEST_EXPECT=0"
        -D "TEST_SKIP_COMPARE=TRUE"
        -D "TEST_OUTPUT=hl_${hl_name}.txt"
        #-D "TEST_REFERENCE=hl_${hl_name}.out"
        -D "TEST_FOLDER=${HDF5_HL_TEST_BINARY_DIR}"
        -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
    )
  endif ()
  if (NOT "${last_test}" STREQUAL "")
    set_tests_properties (HL_${hl_name} PROPERTIES DEPENDS ${last_test}
      ENVIRONMENT "srcdir=${HDF5_HL_TEST_BINARY_DIR}"
      WORKING_DIRECTORY ${HDF5_HL_TEST_BINARY_DIR}
    )
  endif ()
endmacro ()

# Remove any output file left over from previous test run
add_test (
    NAME HL_test-clear-objects
    COMMAND    ${CMAKE_COMMAND}
        -E remove
        combine_tables1.h5
        combine_tables2.h5
        file_img1.h5
        file_img2.h5
        test_append.h5
        h5do_compat.h5
        test_detach.h5
        test_ds1.h5
        test_ds2.h5
        test_ds3.h5
        test_ds4.h5
        test_ds5.h5
        test_ds6.h5
        test_ds7.h5
        test_ds8.h5
        test_ds9.h5
        test_ds10.h5
        test_image1.h5
        test_image2.h5
        test_image3.h5
        test_lite1.h5
        test_lite2.h5
        test_lite3.h5
        test_lite4.h5
        test_packet_compress.h5
        test_packet_table.h5
        test_packet_table_vlen.h5
        testfl_packet_table_vlen.h5
        test_table.h5
)
if (NOT "${last_test}" STREQUAL "")
  set_tests_properties (HL_test-clear-objects PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "HL_test-clear-objects")

HL_add_test (test_lite )
HL_add_test (test_image)
HL_add_test (test_file_image)
HL_add_test (test_table)
HL_add_test (test_ds)
HL_add_test (test_packet)
HL_add_test (test_ld)
HL_add_test (test_dset_append)
HL_add_test (test_h5do_compat)

>)) { QDir d; if (!d.remove(m_outputFile)) QFAIL("Cannot remove old output file!"); } } void tst_QHelpGenerator::generateHelp() { // defined in profile QString path = QLatin1String(SRCDIR); QString inputFile(path + "/data/test.qhp"); QHelpProjectData data; if (!data.readData(inputFile)) QFAIL("Cannot read qthp file!"); QHelpGenerator generator; QCOMPARE(generator.generate(&data, m_outputFile), true); { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "testdb"); db.setDatabaseName(m_outputFile); if (!db.open()) { QSqlDatabase::removeDatabase("testdb"); QFAIL("Created database seems to be corrupt!"); } m_query = new QSqlQuery(db); checkNamespace(); checkFilters(); checkIndices(); checkFiles(); checkMetaData(); m_query->clear(); delete m_query; } QSqlDatabase::removeDatabase("testdb"); // check if db is still in use... initTestCase(); } void tst_QHelpGenerator::checkNamespace() { m_query->exec("SELECT Id, Name FROM NamespaceTable"); if (m_query->next() && m_query->value(1).toString() == QLatin1String("trolltech.com.1_0_0.test")) return; QFAIL("Namespace Error!"); } void tst_QHelpGenerator::checkFilters() { m_query->exec("SELECT COUNT(Id) FROM FilterAttributeTable"); if (!m_query->next() || m_query->value(0).toInt() != 3) QFAIL("FilterAttribute Error!"); m_query->exec("SELECT a.Name FROM FilterAttributeTable a, FilterTable b, " "FilterNameTable c WHERE c.Id=b.NameId AND b.FilterAttributeID=a.Id " "AND c.Name=\'Custom Filter 2\'"); QStringList lst; while (m_query->next()) lst.append(m_query->value(0).toString()); if (!lst.contains("test") || !lst.contains("filter2")) QFAIL("FilterAttribute Error!"); } void tst_QHelpGenerator::checkIndices() { m_query->exec("SELECT a.Name, b.Anchor FROM FileNameTable a, " "IndexTable b, IndexFilterTable c, FilterAttributeTable d " "WHERE a.FileID=b.FileId AND b.Id=c.IndexId " "AND c.FilterAttributeId=d.Id AND d.Name=\'filter1\' AND b.Name=\'foo\'"); if (!m_query->next() || m_query->value(0).toString() != QLatin1String("test.html") || m_query->value(1).toString() != QLatin1String("foo")) QFAIL("Index Error!"); /* m_query->exec("SELECT COUNT(DISTINCT Id) FROM IndexItemTable"); if (!m_query->next() || m_query->value(0).toInt() != 7) QFAIL("Index Error!"); */ m_query->exec("SELECT COUNT(a.Id) FROM IndexTable a, " "IndexFilterTable b, FilterAttributeTable c WHERE a.Id=b.IndexId " "AND b.FilterAttributeId=c.Id AND c.Name=\'filter2\'"); if (!m_query->next() || m_query->value(0).toInt() != 3) QFAIL("Index Error!"); } void tst_QHelpGenerator::checkFiles() { m_query->exec("SELECT COUNT(a.FileId) FROM FileNameTable a, FolderTable b " "WHERE a.FolderId=b.Id AND b.Name=\'testFolder\'"); if (!m_query->next() || m_query->value(0).toInt() != 6) QFAIL("File Error!"); QStringList lst; lst << "classic.css" << "test.html" << "people.html" << "sub/about.html"; m_query->exec("SELECT a.Name FROM FileNameTable a, FileFilterTable b, " "FilterAttributeTable c WHERE c.Id=b.FilterAttributeId " "AND b.FileId=a.FileID AND c.Name=\'filter1\'"); while (m_query->next()) lst.removeAll(m_query->value(0).toString()); QCOMPARE(lst.count(), 0); QMap<int, QStringList> fileAtts; m_query->exec("SELECT a.Id, b.Name FROM FileAttributeSetTable a, " "FilterAttributeTable b WHERE a.FilterAttributeId=b.Id"); while (m_query->next()) { int id = m_query->value(0).toInt(); if (!fileAtts.contains(id)) fileAtts.insert(id, QStringList()); fileAtts[id].append(m_query->value(1).toString()); } QCOMPARE(fileAtts.count(), 2); QCOMPARE((bool)fileAtts.value(1).contains("test"), true); QCOMPARE((bool)fileAtts.value(1).contains("filter1"), true); QCOMPARE((bool)fileAtts.value(1).contains("filter2"), false); QCOMPARE((bool)fileAtts.value(2).contains("test"), true); QCOMPARE((bool)fileAtts.value(2).contains("filter2"), true); } void tst_QHelpGenerator::checkMetaData() { m_query->exec("SELECT COUNT(Value) FROM MetaDataTable"); if (!m_query->next()) QFAIL("Meta Data Error"); QCOMPARE(m_query->value(0).toInt(), 4); m_query->exec("SELECT Value FROM MetaDataTable WHERE Name=\'author\'"); if (!m_query->next()) QFAIL("Meta Data Error"); QCOMPARE(m_query->value(0).toString(), QString("Nokia Corporation and/or its subsidiary(-ies)")); } QTEST_MAIN(tst_QHelpGenerator) #include "tst_qhelpgenerator.moc" #else // QT_NO_BUILD_TOOLS QTEST_NOOP_MAIN #endif