Update unit tests to verify behavior of dynamic mode functions in non-dynamic builds
git-svn-id: https://cld2.googlecode.com/svn/trunk@163 b252ecd4-b096-bf77-eb8e-91563289f87e
This commit is contained in:
@@ -257,15 +257,19 @@ void FinishHtmlOut(int flags) {
|
|||||||
|
|
||||||
#ifdef CLD2_DYNAMIC_MODE
|
#ifdef CLD2_DYNAMIC_MODE
|
||||||
int RunTests (int flags, bool get_vector, const char* data_file) {
|
int RunTests (int flags, bool get_vector, const char* data_file) {
|
||||||
#else
|
#else // CLD2_DYNAMIC_MODE is not defined
|
||||||
int RunTests (int flags, bool get_vector) {
|
int RunTests (int flags, bool get_vector) {
|
||||||
#endif
|
#endif // ifdef CLD2_DYNAMIC_MODE
|
||||||
fprintf(stdout, "CLD2 version: %s\n", CLD2::DetectLanguageVersion());
|
fprintf(stdout, "CLD2 version: %s\n", CLD2::DetectLanguageVersion());
|
||||||
InitHtmlOut(flags);
|
InitHtmlOut(flags);
|
||||||
bool any_fail = false;
|
bool any_fail = false;
|
||||||
|
|
||||||
#ifdef CLD2_DYNAMIC_MODE
|
#ifdef CLD2_DYNAMIC_MODE
|
||||||
fprintf(stdout, "[DYNAMIC] Test running in dynamic data mode!\n");
|
fprintf(stdout, "[DYNAMIC] Test running in dynamic data mode!\n");
|
||||||
|
if (!CLD2::isDataDynamic()) {
|
||||||
|
fprintf(stderr, "[DYNAMIC] *** Error: CLD2::isDataDynamic() returned false in a dynamic build!\n");
|
||||||
|
any_fail = true;
|
||||||
|
}
|
||||||
bool dataLoaded = CLD2::isDataLoaded();
|
bool dataLoaded = CLD2::isDataLoaded();
|
||||||
if (dataLoaded) {
|
if (dataLoaded) {
|
||||||
fprintf(stderr, "[DYNAMIC] *** Error: CLD2::isDataLoaded() returned true prior to loading data from file!\n");
|
fprintf(stderr, "[DYNAMIC] *** Error: CLD2::isDataLoaded() returned true prior to loading data from file!\n");
|
||||||
@@ -281,7 +285,16 @@ int RunTests (int flags, bool get_vector) {
|
|||||||
any_fail = true;
|
any_fail = true;
|
||||||
}
|
}
|
||||||
fprintf(stdout, "[DYNAMIC] Data loaded, file-based tests commencing\n");
|
fprintf(stdout, "[DYNAMIC] Data loaded, file-based tests commencing\n");
|
||||||
#endif
|
#else // CLD2_DYNAMIC_MODE is not defined
|
||||||
|
if (CLD2::isDataDynamic()) {
|
||||||
|
fprintf(stderr, "*** Error: CLD2::isDataDynamic() returned true in a non-dynamic build!\n");
|
||||||
|
any_fail = true;
|
||||||
|
}
|
||||||
|
if (!CLD2::isDataLoaded()) {
|
||||||
|
fprintf(stderr, "*** Error: CLD2::isDataLoaded() returned false in non-dynamic build!\n");
|
||||||
|
any_fail = true;
|
||||||
|
}
|
||||||
|
#endif // ifdef CLD2_DYNAMIC_MODE
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (kTestPair[i].text != NULL) {
|
while (kTestPair[i].text != NULL) {
|
||||||
@@ -348,7 +361,14 @@ int RunTests (int flags, bool get_vector) {
|
|||||||
any_fail |= !OneTest(flags, get_vector, UNKNOWN_LANGUAGE, kTeststr_en, strlen(kTeststr_en));
|
any_fail |= !OneTest(flags, get_vector, UNKNOWN_LANGUAGE, kTeststr_en, strlen(kTeststr_en));
|
||||||
|
|
||||||
fprintf(stdout, "[DYNAMIC] All dynamic-mode tests complete\n");
|
fprintf(stdout, "[DYNAMIC] All dynamic-mode tests complete\n");
|
||||||
#endif
|
#else // CLD2_DYNAMIC_MODE is not defined
|
||||||
|
// These functions should do nothing, and shouldn't cause a crash. A warning is output to STDERR.
|
||||||
|
fprintf(stderr, "Checking that non-dynamic implementations of dynamic data methods are no-ops (ignore the warnings).\n");
|
||||||
|
CLD2::loadDataFromFile("this file doesn't exist");
|
||||||
|
CLD2::loadDataFromRawAddress(NULL, -1);
|
||||||
|
CLD2::unloadData();
|
||||||
|
fprintf(stderr, "Done checking non-dynamic implementations of dynamic data methods, care about warnings again.\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (any_fail) {
|
if (any_fail) {
|
||||||
fprintf(stderr, "FAIL\n");
|
fprintf(stderr, "FAIL\n");
|
||||||
|
@@ -150,15 +150,15 @@ extern const short kAvgDeltaOctaScore[];
|
|||||||
|
|
||||||
void loadDataFromFile(const char* fileName) {
|
void loadDataFromFile(const char* fileName) {
|
||||||
// This is a bug in the calling code.
|
// This is a bug in the calling code.
|
||||||
fprintf(stderr, "WARNING: Dynamic mode not active, loadDataFromFile has no effect!");
|
fprintf(stderr, "WARNING: Dynamic mode not active, loadDataFromFile has no effect!\n");
|
||||||
}
|
}
|
||||||
void loadDataFromRawAddress(const void* rawAddress, const uint32_t length) {
|
void loadDataFromRawAddress(const void* rawAddress, const uint32_t length) {
|
||||||
// This is a bug in the calling code.
|
// This is a bug in the calling code.
|
||||||
fprintf(stderr, "WARNING: Dynamic mode not active, loadDataFromRawAddress has no effect!");
|
fprintf(stderr, "WARNING: Dynamic mode not active, loadDataFromRawAddress has no effect!\n");
|
||||||
}
|
}
|
||||||
void unloadData() {
|
void unloadData() {
|
||||||
// This is a bug in the calling code.
|
// This is a bug in the calling code.
|
||||||
fprintf(stderr, "WARNING: Dynamic mode not active, unloadData has no effect!");
|
fprintf(stderr, "WARNING: Dynamic mode not active, unloadData has no effect!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifdef CLD2_DYNAMIC_MODE
|
#endif // #ifdef CLD2_DYNAMIC_MODE
|
||||||
|
@@ -22,9 +22,9 @@ echo "--> [1 of 7] Invoking: compile.sh..."
|
|||||||
echo "--> [2 of 7] Testing results of compile.sh..."
|
echo "--> [2 of 7] Testing results of compile.sh..."
|
||||||
echo "--> compact_lang_det_test_chrome... "
|
echo "--> compact_lang_det_test_chrome... "
|
||||||
echo "this is some english text" | ./compact_lang_det_test_chrome
|
echo "this is some english text" | ./compact_lang_det_test_chrome
|
||||||
echo -n "--> cld2_unittest... "
|
echo "--> cld2_unittest... "
|
||||||
./cld2_unittest > /dev/null
|
./cld2_unittest > /dev/null
|
||||||
echo -n "--> cld2_unittest_avoid... "
|
echo "--> cld2_unittest_avoid... "
|
||||||
./cld2_unittest_avoid > /dev/null
|
./cld2_unittest_avoid > /dev/null
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
@@ -37,9 +37,9 @@ echo "--> [4 of 7] Invoking: compile_full.sh..."
|
|||||||
echo "--> [5 of 7] Testing results of compile_full.sh..."
|
echo "--> [5 of 7] Testing results of compile_full.sh..."
|
||||||
echo "--> compact_lang_det_test_full... "
|
echo "--> compact_lang_det_test_full... "
|
||||||
echo "this is some english text" | ./compact_lang_det_test_full
|
echo "this is some english text" | ./compact_lang_det_test_full
|
||||||
echo -n "--> cld2_unittest_full... "
|
echo "--> cld2_unittest_full... "
|
||||||
./cld2_unittest_full > /dev/null
|
./cld2_unittest_full > /dev/null
|
||||||
echo -n "--> cld2_unittest_full_avoid... "
|
echo "--> cld2_unittest_full_avoid... "
|
||||||
./cld2_unittest_full_avoid > /dev/null
|
./cld2_unittest_full_avoid > /dev/null
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
@@ -52,7 +52,7 @@ echo "--> [6 of 7] Verifying dynamic data in cld2_data.bin..."
|
|||||||
echo "--> [7 of 7] Testing results of compile_dynamic.sh..."
|
echo "--> [7 of 7] Testing results of compile_dynamic.sh..."
|
||||||
echo "--> compact_lang_det_dynamic_test_chrome... "
|
echo "--> compact_lang_det_dynamic_test_chrome... "
|
||||||
echo "this is some english text" | ./compact_lang_det_dynamic_test_chrome --data-file cld2_data.bin
|
echo "this is some english text" | ./compact_lang_det_dynamic_test_chrome --data-file cld2_data.bin
|
||||||
echo -n "--> cld2_dynamic_unittest... "
|
echo "--> cld2_dynamic_unittest... "
|
||||||
./cld2_dynamic_unittest --data-file cld2_data.bin > /dev/null
|
./cld2_dynamic_unittest --data-file cld2_data.bin > /dev/null
|
||||||
|
|
||||||
trap - INT TERM EXIT
|
trap - INT TERM EXIT
|
||||||
|
Reference in New Issue
Block a user