static void testCommandsHandling(void) { #define TEST_INPUT(data, output) { \ SCPI_Input(&scpi_context, data, strlen(data)); \ CU_ASSERT_STRING_EQUAL(output, output_buffer); \ } output_buffer_clear(); error_buffer_clear(); /* Test single command */ TEST_INPUT("*IDN?\r\n", "MA,IN,0,VER\r\n"); output_buffer_clear(); /* Test multiple commands in input buffer */ TEST_INPUT("*IDN?\r\n*IDN?\r\n*IDN?\r\n*IDN?\r\n", "MA,IN,0,VER\r\nMA,IN,0,VER\r\nMA,IN,0,VER\r\nMA,IN,0,VER\r\n"); output_buffer_clear(); TEST_INPUT("*IDN?;*IDN?;*IDN?;*IDN?\r\n", "MA,IN,0,VER;MA,IN,0,VER;MA,IN,0,VER;MA,IN,0,VER\r\n"); output_buffer_clear(); TEST_INPUT("*IDN?;*OPC;*IDN?\r\n", "MA,IN,0,VER;MA,IN,0,VER\r\n"); output_buffer_clear(); /* Test one command in multiple buffers */ TEST_INPUT("*IDN?", ""); TEST_INPUT("\r\n", "MA,IN,0,VER\r\n"); output_buffer_clear(); /* Test input "timeout" - input with length == 0 */ TEST_INPUT("*IDN?", ""); TEST_INPUT("", "MA,IN,0,VER\r\n"); output_buffer_clear(); /* Test ctree traversal */ TEST_INPUT("TEST:TREEA?;TREEB?\r\n", "10;20\r\n"); output_buffer_clear(); TEST_INPUT("TEST:TREEA?;:TEXT? \"PARAM1\", \"PARAM2\"\r\n", "10;\"PARAM2\"\r\n"); output_buffer_clear(); CU_ASSERT_EQUAL(err_buffer_pos, 0); error_buffer_clear(); }
ATF_TC_BODY(isc_gost_md, tc) { isc_gost_t gost; isc_result_t result; UNUSED(tc); /* * These are the various test vectors. All of these are passed * through the hash function and the results are compared to the * result specified here. */ hash_testcase_t testcases[] = { /* Test 1 */ { TEST_INPUT(""), "0x981E5F3CA30C841487830F84FB433E1" "3AC1101569B9C13584AC483234CD656C0", 1 }, /* Test 2 */ { TEST_INPUT("a"), "0xE74C52DD282183BF37AF0079C9F7805" "5715A103F17E3133CEFF1AACF2F403011", 1 }, /* Test 3 */ { TEST_INPUT("abc"), "0xB285056DBF18D7392D7677369524DD1" "4747459ED8143997E163B2986F92FD42C", 1 }, /* Test 4 */ { TEST_INPUT("message digest"), "0xBC6041DD2AA401EBFA6E9886734174F" "EBDB4729AA972D60F549AC39B29721BA0", 1 }, /* Test 5 */ { TEST_INPUT("The quick brown fox jumps " "over the lazy dog"), "0x9004294A361A508C586FE53D1F1B027" "46765E71B765472786E4770D565830A76", 1 }, /* Test 6 */ { TEST_INPUT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcde" "fghijklmnopqrstuvwxyz0123456789"), "0x73B70A39497DE53A6E08C67B6D4DB85" "3540F03E9389299D9B0156EF7E85D0F61", 1 }, /* Test 7 */ { TEST_INPUT("1234567890123456789012345678901" "2345678901234567890123456789012" "345678901234567890"), "0x6BC7B38989B28CF93AE8842BF9D7529" "05910A7528A61E5BCE0782DE43E610C90", 1 }, /* Test 8 */ { TEST_INPUT("This is message, length=32 bytes"), "0x2CEFC2F7B7BDC514E18EA57FA74FF35" "7E7FA17D652C75F69CB1BE7893EDE48EB", 1 }, /* Test 9 */ { TEST_INPUT("Suppose the original message " "has length = 50 bytes"), "0xC3730C5CBCCACF915AC292676F21E8B" "D4EF75331D9405E5F1A61DC3130A65011", 1 }, /* Test 10 */ { TEST_INPUT("U") /* times 128 */, "0x1C4AC7614691BBF427FA2316216BE8F" "10D92EDFD37CD1027514C1008F649C4E8", 128 }, /* Test 11 */ { TEST_INPUT("a") /* times 1000000 */, "0x8693287AA62F9478F7CB312EC0866B6" "C4E4A0F11160441E8F4FFCD2715DD554F", 1000000 }, { NULL, 0, NULL, 1 } }; result = dns_test_begin(NULL, ISC_FALSE); ATF_REQUIRE(result == ISC_R_SUCCESS); hash_testcase_t *testcase = testcases; while (testcase->input != NULL && testcase->result != NULL) { result = isc_gost_init(&gost); ATF_REQUIRE(result == ISC_R_SUCCESS); for(i = 0; i < testcase->repeats; i++) { result = isc_gost_update(&gost, (const isc_uint8_t *) testcase->input, testcase->input_len); ATF_REQUIRE(result == ISC_R_SUCCESS); } result = isc_gost_final(&gost, digest); ATF_REQUIRE(result == ISC_R_SUCCESS); tohexstr(digest, ISC_GOST_DIGESTLENGTH, str); ATF_CHECK_STREQ(str, testcase->result); testcase++; } dns_test_end(); }