void TestFileFinderInterface() throw(Exception) { FileFinder base_file("global/test/data/random_data.txt", RelativeTo::ChasteSourceRoot); FileFinder noised_file("global/test/data/same_random_data_with_1e-4_noise.txt", RelativeTo::ChasteSourceRoot); FileComparison same_data(base_file, noised_file, CalledCollectively, SuppressOutput); TS_ASSERT_EQUALS(same_data.CompareFiles(0,false), expected_fail_result); }
// By default the class expects to be used collectively, so only the master does file operations, // and there's a barrier before opening the files. This case is "tested" in the other // tests - it's working if they don't deadlock! Here we test the ability to be used non-collectively. void TestParallelOperation() throw(Exception) { CalledCollectively = false; if (PetscTools::AmMaster()) { std::string base_file = "./global/test/data/random_data.txt"; FileComparison same_data(base_file, base_file, CalledCollectively); TS_ASSERT(same_data.CompareFiles()); } CalledCollectively = true; }
static krb5_error_code check_realm_in_list (krb5_data *realm, void *data) { struct check_data *cdata = data; int i; Tprintf ((".. checking '%.*s'\n", (int) realm->length, realm->data)); for (i = 0; cdata->tgs[i]; i++) { if (same_data (krb5_princ_realm (cdata->ctx, cdata->tgs[i]), realm)) return 0; } Tprintf (("BAD!\n")); return KRB5KRB_AP_ERR_ILL_CR_TKT; }
void TestBasicFunctionality() throw(Exception) { std::string base_file = "./global/test/data/random_data.txt"; std::string noised_file = "./global/test/data/same_random_data_with_1e-4_noise.txt"; CalledCollectively = true; SuppressOutput = true; expected_fail_result = !PetscTools::AmMaster(); // Comparing identical files shows no difference // NB Last two arguments can generally take their defaults (true and false) FileComparison same_data(base_file, base_file, CalledCollectively, SuppressOutput); TS_ASSERT(same_data.CompareFiles()); // Comparing two different files gives a failure. FileComparison different_data(base_file, noised_file, CalledCollectively, SuppressOutput); TS_ASSERT_EQUALS(different_data.CompareFiles(0,false), expected_fail_result); }
// check all still allocated blocks in a test sequence // contain the data originally placed into them // i.e. have not been corrupted int check_data(SEQLIST *test_sequence) { int result; SEQLIST *current; result = 0; // stays zero if no errors for (current = test_sequence; !seq_null(current); current = seq_next(current)) { // only check if an allocate which has not been freed if (seq_alloc(current) && !seq_freed(current)) { if (!same_data(seq_ref_block(current), seq_myalloc_block(current), seq_size(current))) { if (VERBOSE) { printf("Mismatch in sequence starting at:\n"); seq_print(current); } // returning a 1 means it failed result = 1; } } } return result; }