Esempio n. 1
0
void
VerifyOpenSSLCMAC(struct key *cmac)
{
#ifdef OPENSSL

	/* XXX: HMS: auth_md5 must be renamed/incorrect. */
	// TEST_ASSERT_TRUE(auth_md5(PKT_DATA, PKT_LEN, CMAC_LENGTH, cmac));
	TEST_IGNORE_MESSAGE("VerifyOpenSSLCMAC needs to be implemented, skipping...");

#else
	
	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
	
#endif	/* OPENSSL */
	return;
}
Esempio n. 2
0
void
test_MakeSHA1Mac(void)
{
#ifdef OPENSSL

	const char* PKT_DATA = "abcdefgh0123";
	const int PKT_LEN = strlen(PKT_DATA);
	const char* EXPECTED_DIGEST =
		"\x17\xaa\x82\x97\xc7\x17\x13\x6a\x9b\xa9"
		"\x63\x85\xb4\xce\xbe\x94\xa0\x97\x16\x1d";
	char actual[SHA1_LENGTH];

	struct key sha1;
	sha1.next = NULL;
	sha1.key_id = 20;
	sha1.key_len = 7;
	memcpy(&sha1.key_seq, "sha1seq", sha1.key_len);
	memcpy(&sha1.type, "SHA1", 5);

	TEST_ASSERT_EQUAL(SHA1_LENGTH,
			  make_mac(PKT_DATA, PKT_LEN, SHA1_LENGTH, &sha1, actual));

	TEST_ASSERT_EQUAL_MEMORY(EXPECTED_DIGEST, actual, SHA1_LENGTH);
	
#else
	
	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
	
#endif	/* OPENSSL */
}
Esempio n. 3
0
void 
test_ScopedIPv6AddressWithPort(void) {
#ifdef ISC_PLATFORM_HAVESCOPEID
	const struct in6_addr address = { { {
		0xfe, 0x80, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00,
		0x02, 0x12, 0x3f, 0xff, 
		0xfe, 0x29, 0xff, 0xfa
	} } };

	const char* expected =
		"fe80::212:3fff:fe29:fffa%5";
	const char* expected_port = 
		"[fe80::212:3fff:fe29:fffa%5]:123";

	sockaddr_u input;
	memset(&input, 0, sizeof(input));
	AF(&input) = AF_INET6;
	SET_ADDR6N(&input, address);
	SET_PORT(&input, 123);
	SCOPE_VAR(&input) = 5;

	TEST_ASSERT_EQUAL_STRING(expected, socktoa(&input));
	TEST_ASSERT_EQUAL_STRING(expected_port, sockporttoa(&input));
#else
	TEST_IGNORE_MESSAGE("Skipping because ISC_PLATFORM does not have Scope ID");
#endif
}
Esempio n. 4
0
void
test_VerifySHA1(void)
{
#ifdef OPENSSL

	const char* PKT_DATA =
	    "sometestdata"				/* Data */
	    "\0\0\0\0"					/* Key-ID (unused) */
	    "\xad\x07\xde\x36\x39\xa6\x77\xfa\x5b\xce"	/* MAC */
	    "\x2d\x8a\x7d\x06\x96\xe6\x0c\xbc\xed\xe1";
	const int PKT_LEN = 12;

	struct key sha1;
	sha1.next = NULL;
	sha1.key_id = 0;
	sha1.key_len = 7;
	memcpy(&sha1.key_seq, "sha1key", sha1.key_len);
	memcpy(&sha1.type, "SHA1", 5);

	TEST_ASSERT_TRUE(auth_md5(PKT_DATA, PKT_LEN, SHA1_LENGTH, &sha1));
	
#else
	
	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
	
#endif	/* OPENSSL */
}
Esempio n. 5
0
void
test_IntegerAndFractionalBuffer(void)
{
#ifndef SYS_WINNT
	const struct timeval input = {5, 500000}; /* 5.5 */
	const l_fp expected = {{5 + JAN_1970}, HALF};
	double expectedDouble, actualDouble;
	l_fp actual;

	TEST_ASSERT_TRUE(buftvtots((const char*)(&input), &actual));

	/* Compare the fractional part with an absolute error given. */
	TEST_ASSERT_EQUAL(expected.l_ui, actual.l_ui);

	M_LFPTOD(0, expected.l_uf, expectedDouble);
	M_LFPTOD(0, actual.l_uf, actualDouble);

	/* The error should be less than 0.5 us */
	TEST_ASSERT_DOUBLE_WITHIN(0.0000005, expectedDouble, actualDouble);
#else
	TEST_IGNORE_MESSAGE("Test only for Windows, skipping...");
#endif

	return;
}
Esempio n. 6
0
void
test_mactable_cmd_dump_not_found(void) {
#ifdef HYBRID
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  char *str = NULL;
  const char format_str[] =
    "{\"name\":\":hoge\",\n"
    "\"mactable\":[{";
  char test_str[1000];

  uint8_t eth[6];
  uint32_t port = 1;

  /* add mac entries */
  eth[0] = 0xaa;
  eth[1] = 0xbb;
  eth[2] = 0xcc;
  eth[3] = 0xdd;
  eth[4] = 0xee;
  eth[5] = 0xff;

  ret = dp_bridge_mactable_entry_set(bridge_name, eth, port);
  TEST_ASSERT_EQUAL(ret, LAGOPUS_RESULT_OK);
  sprintf(test_str, format_str);

  /* test target. */
  (void) lagopus_dstring_clear(&ds);
  ret = dump_bridge_mactable(":hoge", is_bridge_first, &ds);
  TEST_ASSERT_EQUAL(ret, LAGOPUS_RESULT_NOT_FOUND);
  TEST_DSTRING(ret, &ds, str, test_str, false);
#else /* HYBRID */
  TEST_IGNORE_MESSAGE("HYBRID is not defined.");
#endif /* HYBRID */
}
Esempio n. 7
0
void
test_MakeCMac(void)
{
#ifdef OPENSSL

	const char* PKT_DATA = "abcdefgh0123";
	const int PKT_LEN = strlen(PKT_DATA);
	const char* EXPECTED_DIGEST =
		"\xdd\x35\xd5\xf5\x14\x23\xd9\xd6"
		"\x38\x5d\x29\x80\xfe\x51\xb9\x6b";
	char actual[CMAC_LENGTH];

	struct key cmac;
	cmac.next = NULL;
	cmac.key_id = 30;
	cmac.key_len = CMAC_LENGTH;
	memcpy(&cmac.key_seq, "aes-128-cmac-seq", cmac.key_len);
	memcpy(&cmac.typen, CMAC, strlen(CMAC) + 1);

	TEST_ASSERT_EQUAL(CMAC_LENGTH,
		    make_mac(PKT_DATA, PKT_LEN, CMAC_LENGTH, &cmac, actual));

	TEST_ASSERT_EQUAL_MEMORY(EXPECTED_DIGEST, actual, CMAC_LENGTH);
	
#else
	
	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
	
#endif	/* OPENSSL */
}
Esempio n. 8
0
void 
test_IgnoreIPv6Fields(void) {

#ifdef ISC_PLATFORM_WANTIPV6

	const struct in6_addr address = {
		0x20, 0x01, 0x0d, 0xb8,
        0x85, 0xa3, 0x08, 0xd3, 
        0x13, 0x19, 0x8a, 0x2e,
        0x03, 0x70, 0x73, 0x34
	};

	sockaddr_u input1, input2;

	input1.sa6.sin6_family = AF_INET6;
	input1.sa6.sin6_addr = address;
	input1.sa6.sin6_flowinfo = 30L; // This value differs from input2.
	SET_PORT(&input1, NTP_PORT);

	input2.sa6.sin6_family = AF_INET6;
	input2.sa6.sin6_addr = address;
	input2.sa6.sin6_flowinfo = 10L; // This value differs from input1.
	SET_PORT(&input2, NTP_PORT);

	TEST_ASSERT_EQUAL(sock_hash(&input1), sock_hash(&input2));

#else
	TEST_IGNORE_MESSAGE("IPV6 disabled in build, skipping.");
#endif /* ISC_PLATFORM_HAVEIPV6 */
}
Esempio n. 9
0
void test_SHA1KeyName() {
#ifdef OPENSSL
	TEST_ASSERT_EQUAL_STRING("SHA", keytype_name(NID_sha));
#else
	TEST_IGNORE_MESSAGE("Skipping because OPENSSL isn't defined");
#endif	/* OPENSSL */
}
Esempio n. 10
0
void
test_IPv6AddressWithPort(void)
{
#ifdef ISC_PLATFORM_WANTIPV6

	const struct in6_addr address = {
		0x20, 0x01, 0x0d, 0xb8,
		0x85, 0xa3, 0x08, 0xd3,
		0x13, 0x19, 0x8a, 0x2e,
		0x03, 0x70, 0x73, 0x34
	};

	const char *str = "[2001:0db8:85a3:08d3:1319:8a2e:0370:7334]:3000";
	sockaddr_u actual;

	sockaddr_u expected;
	expected.sa6.sin6_family = AF_INET6;
	expected.sa6.sin6_addr = address;
	SET_PORT(&expected, 3000);

	TEST_ASSERT_TRUE(decodenetnum(str, &actual));
	TEST_ASSERT_TRUE(IsEqual(expected, actual));

#else
	
	TEST_IGNORE_MESSAGE("IPV6 disabled in build, skipping.");
	
#endif /* ISC_PLATFORM_HAVEIPV6 */
}
Esempio n. 11
0
void
test_LocalClock(void) {
#ifdef REFCLOCK		/* clockname() is useless otherwise */
	/* We test with a refclock address of type LOCALCLOCK.
	 * with id 8
	 */
	u_int32 addr = REFCLOCK_ADDR;
	addr |= REFCLK_LOCALCLOCK << 8;
	addr |= 0x8;

	sockaddr_u address;
	address.sa4.sin_family = AF_INET;
	address.sa4.sin_addr.s_addr = htonl(addr);
	
	char stringStart[100]= "";

	strcat(stringStart, clockname(REFCLK_LOCALCLOCK));
	strcat(stringStart, "(8)");

	char * expected = stringStart;

	TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
#else	
	TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");
#endif	/* REFCLOCK */
}
Esempio n. 12
0
void 
test_IPv6AddressWithPort(void) {

#ifdef ISC_PLATFORM_WANTIPV6

	const struct in6_addr address = {
		0x20, 0x01, 0x0d, 0xb8,
		0x85, 0xa3, 0x08, 0xd3, 
		0x13, 0x19, 0x8a, 0x2e,
		0x03, 0x70, 0x73, 0x34
	};

	const char* expected =
		"2001:db8:85a3:8d3:1319:8a2e:370:7334";
	const char* expected_port = 
		"[2001:db8:85a3:8d3:1319:8a2e:370:7334]:123";

	sockaddr_u input;
	memset(&input, 0, sizeof(input));
	AF(&input) = AF_INET6;
	SET_ADDR6N(&input, address);
	SET_PORT(&input, 123);

	TEST_ASSERT_EQUAL_STRING(expected, socktoa(&input));
	TEST_ASSERT_EQUAL_STRING(expected_port, sockporttoa(&input));

#else
	TEST_IGNORE_MESSAGE("IPV6 disabled in build, skipping.");

#endif /* ISC_PLATFORM_HAVEIPV6 */

}
Esempio n. 13
0
void test_poller_exists_with_socket_on_zmq_ctx_term (const int socket_type_)
{
#ifdef ZMQ_HAVE_POLLER
    struct poller_test_data_t poller_test_data;

    poller_test_data.socket_type = socket_type_;

    //  Set up our context and sockets
    poller_test_data.ctx = zmq_ctx_new ();
    TEST_ASSERT_NOT_NULL (poller_test_data.ctx);

    poller_test_data.counter = zmq_atomic_counter_new ();
    TEST_ASSERT_NOT_NULL (poller_test_data.counter);

    void *thread = zmq_threadstart (run_poller, &poller_test_data);
    TEST_ASSERT_NOT_NULL (thread);

    while (zmq_atomic_counter_value (poller_test_data.counter) == 0) {
        msleep (10);
    }

    // Destroy the context
    TEST_ASSERT_SUCCESS_ERRNO (zmq_ctx_destroy (poller_test_data.ctx));

    zmq_threadclose (thread);

    zmq_atomic_counter_destroy (&poller_test_data.counter);
#else
    TEST_IGNORE_MESSAGE ("libzmq without zmq_poller_* support, ignoring test");
#endif
}
Esempio n. 14
0
void testIgnoreMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_IGNORE_MESSAGE("This is an expected TEST_IGNORE_MESSAGE string!");
    TEST_FAIL_MESSAGE("This should not be reached");
    VERIFY_IGNORES_END
}
Esempio n. 15
0
void test_KineticPDU_Send_should_send_the_PDU_and_return_true_upon_successful_transmission_of_full_PDU_with_value_payload(void)
{
    LOG_LOCATION;
    ByteBuffer headerNBO = ByteBuffer_Create(&PDU.headerNBO, sizeof(KineticPDUHeader));

    KINETIC_PDU_INIT_WITH_MESSAGE(&PDU, &Connection);
    uint8_t valueData[128];
    ByteBuffer valueBuffer = ByteBuffer_Create(valueData, sizeof(valueData));
    ByteBuffer_AppendCString(&valueBuffer, "Some arbitrary value");
    KineticEntry entry = {.value = valueBuffer};
    KineticPDU_AttachEntry(&PDU, &entry);

    KineticHMAC_Init_Expect(&PDU.hmac, KINETIC_PROTO_SECURITY_ACL_HMACALGORITHM_HmacSHA1);
    KineticHMAC_Populate_Expect(&PDU.hmac,
                                &PDU.protoData.message.proto, PDU.connection->session.hmacKey);
    KineticSocket_Write_ExpectAndReturn(Connection.socket, &headerNBO, KINETIC_STATUS_SUCCESS);
    KineticSocket_WriteProtobuf_ExpectAndReturn(Connection.socket, &PDU, KINETIC_STATUS_SUCCESS);
    KineticSocket_Write_ExpectAndReturn(Connection.socket, &PDU.entry.value, KINETIC_STATUS_SUCCESS);

    TEST_IGNORE_MESSAGE("Need to figure out how to handle address of PDU header");

    KineticStatus status = KineticPDU_Send(&PDU);

    TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status);
}
Esempio n. 16
0
void test_KineticPDU_Send_should_send_the_PDU_and_return_true_upon_successful_transmission_of_full_PDU_with_no_value_payload(void)
{
    LOG_LOCATION;
    KINETIC_PDU_INIT_WITH_MESSAGE(&PDU, &Connection);
    ByteBuffer headerNBO = ByteBuffer_Create(&PDU.headerNBO, sizeof(KineticPDUHeader));

    KineticEntry entry = {.value = BYTE_BUFFER_NONE};
    KineticPDU_AttachEntry(&PDU, &entry);

    // Create NBO copy of header for sending
    PDU.headerNBO.versionPrefix = 'F';
    PDU.headerNBO.protobufLength =
        KineticNBO_FromHostU32(KineticProto__get_packed_size(PDU.proto));
    PDU.headerNBO.valueLength = 0;

    KineticHMAC_Init_Expect(&PDU.hmac,
                            KINETIC_PROTO_SECURITY_ACL_HMACALGORITHM_HmacSHA1);
    KineticHMAC_Populate_Expect(&PDU.hmac,
                                &PDU.protoData.message.proto, PDU.connection->session.hmacKey);
    KineticSocket_Write_ExpectAndReturn(Connection.socket, &headerNBO, KINETIC_STATUS_SUCCESS);
    KineticSocket_WriteProtobuf_ExpectAndReturn(Connection.socket, &PDU, KINETIC_STATUS_SUCCESS);

    TEST_IGNORE_MESSAGE("Need to figure out how to handle address of PDU header");

    KineticStatus status = KineticPDU_Send(&PDU);

    TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status);
}
Esempio n. 17
0
void
test_mactable_cmd_dump_02(void) {
#ifdef HYBRID
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  char *str = NULL;
  const char format_str[] =
    "{\"name\":\":br0\",\n"
    "\"mactable\":[{\"num_entries\":2,\n"
    "\"max_entries\":8192,\n"
    "\"ageing_time\":300,\n"
    "\"entries\":[{\"mac_addr\":\"1a:2b:3c:4d:5e:6f\",\n"
    "\"port_no\":2,\n"
    "\"update_time\":%ld,\n"
    "\"address_type\":\"static\"},\n"
    "{\"mac_addr\":\"aa:bb:cc:dd:ee:ff\",\n"
    "\"port_no\":1,\n"
    "\"update_time\":%ld,\n"
    "\"address_type\":\"static\"}]}]}";
  char test_str[1000];
  uint8_t eth1[6];
  uint8_t eth2[6];
  uint32_t port1 = 1;
  uint32_t port2 = 2;
  struct timespec now;
  struct bridge *bridge;

  /* add mac entries */
  eth1[0] = 0xaa;
  eth1[1] = 0xbb;
  eth1[2] = 0xcc;
  eth1[3] = 0xdd;
  eth1[4] = 0xee;
  eth1[5] = 0xff;
  eth2[0] = 0x1a;
  eth2[1] = 0x2b;
  eth2[2] = 0x3c;
  eth2[3] = 0x4d;
  eth2[4] = 0x5e;
  eth2[5] = 0x6f;

  /* preparation */
  ret = dp_bridge_mactable_entry_set(bridge_name, eth1, port1);
  TEST_ASSERT_EQUAL(ret, LAGOPUS_RESULT_OK);
  ret = dp_bridge_mactable_entry_set(bridge_name, eth2, port2);
  TEST_ASSERT_EQUAL(ret, LAGOPUS_RESULT_OK);
  now = get_current_time();
  sprintf(test_str, format_str, now.tv_sec, now.tv_sec);
  bridge = dp_bridge_lookup(bridge_name);
  mactable_update(&bridge->mactable);

  /* test target. */
  (void) lagopus_dstring_clear(&ds);
  ret = dump_bridge_mactable(bridge_name, is_bridge_first, &ds);
  TEST_ASSERT_EQUAL(ret, LAGOPUS_RESULT_OK);
  TEST_DSTRING(ret, &ds, str, test_str, true);
#else /* HYBRID */
  TEST_IGNORE_MESSAGE("HYBRID is not defined.");
#endif /* HYBRID */
}
Esempio n. 18
0
void test_poller_exists_with_socket_on_zmq_ctx_term_thread_safe_socket ()
{
#ifdef ZMQ_BUILD_DRAFT_API
    test_poller_exists_with_socket_on_zmq_ctx_term (ZMQ_CLIENT);
#else
    TEST_IGNORE_MESSAGE ("libzmq without DRAFT support, ignoring test");
#endif
}
Esempio n. 19
0
void
test_destroy(void) {
#ifdef HYBRID
  destroy = true;
#else /* HYBRID */
  TEST_IGNORE_MESSAGE("HYBRID is not defined.");
#endif /* HYBRID */
}
Esempio n. 20
0
void
test_NtpToTime(void)
{
#   if SIZEOF_TIME_T <= 4
	
	TEST_IGNORE_MESSAGE("test only useful for sizeof(time_t) > 4, skipped");
	
#   else
	
	static const uint32_t ntp_vals[6] = {
		UINT32_C(0x00000000),
		UINT32_C(0x00000001),
		UINT32_C(0x7FFFFFFF),
		UINT32_C(0x80000000),
		UINT32_C(0x80000001),
		UINT32_C(0xFFFFFFFF)
	};

	static char	lbuf[128];
	vint64		hold;
	time_t		pivot, texp, diff;
	uint32_t	back;
	int		loops, iloop;
	
	pivot = 0;
	for (loops = 0; loops < 16; ++loops) {
		for (iloop = 0; iloop < 6; ++iloop) {
			hold = ntpcal_ntp_to_time(
				ntp_vals[iloop], &pivot);
			texp = vint64_to_time(&hold);

			/* constraint 1: texp must be in the
			 * (right-open) intervall [p-(2^31), p+(2^31)[
			 */
			diff = texp - pivot;
			snprintf(lbuf, sizeof(lbuf),
				 "bounds check: piv=%lld exp=%lld dif=%lld",
				 (long long)pivot,
				 (long long)texp,
				 (long long)diff);
			TEST_ASSERT_MESSAGE((diff >= INT32_MIN) && (diff <= INT32_MAX),
					    lbuf);

			/* constraint 2: conversion from full time back
			 * to truncated NTP time must yield same result
			 * as input.
			*/
			back = (uint32_t)texp + JAN_1970;
			snprintf(lbuf, sizeof(lbuf),
				 "modulo check: ntp(in)=$%08lu ntp(out)=$%08lu",
				 (unsigned long)ntp_vals[iloop],
				 (unsigned long)back);
			TEST_ASSERT_EQUAL_MESSAGE(ntp_vals[iloop], back, lbuf);
		}
		pivot += 0x20000000;
	}
#   endif
}
Esempio n. 21
0
void
test_NtpToNtp(void)
{
#   if SIZEOF_TIME_T <= 4
	
	TEST_IGNORE_MESSAGE("test only useful for sizeof(time_t) > 4, skipped");

#   else
	
	static const uint32_t ntp_vals[6] = {
		UINT32_C(0x00000000),
		UINT32_C(0x00000001),
		UINT32_C(0x7FFFFFFF),
		UINT32_C(0x80000000),
		UINT32_C(0x80000001),
		UINT32_C(0xFFFFFFFF)
	};

	static char	lbuf[128];
	vint64		hold;
	time_t		pivot, texp, diff;
	int		loops, iloop;
	
	pivot = 0;
	for (loops = 0; loops < 16; ++loops) {
		for (iloop = 0; iloop < 6; ++iloop) {
			hold = ntpcal_ntp_to_ntp(
				ntp_vals[iloop], &pivot);
			texp = vint64_to_time(&hold);

			/* constraint 1: texp must be in the
			 * (right-open) intervall [p-(2^31), p+(2^31)[,
			 * but the pivot 'p' must be taken in full NTP
			 * time scale!
			 */
			diff = texp - (pivot + JAN_1970);
			snprintf(lbuf, sizeof(lbuf),
				 "bounds check: piv=%lld exp=%lld dif=%lld",
				 (long long)pivot,
				 (long long)texp,
				 (long long)diff);
			TEST_ASSERT_MESSAGE((diff >= INT32_MIN) && (diff <= INT32_MAX),
					    lbuf);

			/* constraint 2: low word must be equal to
			 * input
			 */
			snprintf(lbuf, sizeof(lbuf),
				 "low check: ntp(in)=$%08lu ntp(out[0:31])=$%08lu",
				 (unsigned long)ntp_vals[iloop],
				 (unsigned long)hold.D_s.lo);
			TEST_ASSERT_EQUAL_MESSAGE(ntp_vals[iloop], hold.D_s.lo, lbuf);
		}
		pivot += 0x20000000;
	}
#   endif
}
Esempio n. 22
0
void
VerifyLocalCMAC(struct key *cmac)
{

	/* XXX: HMS: auth_md5 must be renamed/incorrect. */
	// TEST_ASSERT_TRUE(auth_md5(PKT_DATA, PKT_LEN, CMAC_LENGTH, cmac));

	TEST_IGNORE_MESSAGE("Hook in the local AES-128-CMAC check!");

	return;
}
Esempio n. 23
0
void test_IllegalMicroseconds() {
#ifndef SYS_WINNT
	const struct timeval input = {0, 1100000}; // > 999 999 microseconds.
	
	l_fp actual;

	TEST_ASSERT_FALSE(buftvtots((const char*)(&input), &actual));
#else
	TEST_IGNORE_MESSAGE("Test only for Windows, skipping...");
#endif
}
Esempio n. 24
0
void test_SHA1KeyTypeWithDigestLength() {
#ifdef OPENSSL
	size_t digestLength;
	size_t expected = TEST_SHA1_DIGEST_LENGTH;

	TEST_ASSERT_EQUAL(NID_sha, keytype_from_text("SHA", &digestLength));
	TEST_ASSERT_EQUAL(expected, digestLength);
	/* OPENSSL */
#else 
	TEST_IGNORE_MESSAGE("Skipping because OPENSSL isn't defined");
#endif
}
Esempio n. 25
0
void test_AlwaysFalseOnWindows() {
#ifdef SYS_WINNT
	/*
	 * Under Windows, buftvtots will just return
	 * 0 (false).
	 */
	l_fp actual;
	TEST_ASSERT_FALSE(buftvtots("", &actual));
#else
	TEST_IGNORE_MESSAGE("Non-Windows test, skipping...");
#endif
}
Esempio n. 26
0
void test_usbd_init_ok(void)
{
  TEST_IGNORE_MESSAGE("pause device stack");
  dcd_init_ExpectAndReturn(TUSB_ERROR_NONE);

  hidd_init_StubWithCallback(stub_hidd_init);

  dcd_controller_connect_Expect(0);

  //------------- Code Under Test -------------//
  TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, usbd_init() );

}
Esempio n. 27
0
void test_ZeroBuffer() {
#ifndef SYS_WINNT
	const struct timeval input = {0, 0};
	const l_fp expected = {0 + JAN_1970, 0};

	l_fp actual;

	TEST_ASSERT_TRUE(buftvtots((const char*)(&input), &actual));
	TEST_ASSERT_TRUE(IsEqual(expected, actual));
#else
	TEST_IGNORE_MESSAGE("Test only for Windows, skipping...");
#endif
}
Esempio n. 28
0
void testIgnoreMessage(void)
{
    int ignored;

    EXPECT_ABORT_BEGIN
    TEST_IGNORE_MESSAGE("This is an expected TEST_IGNORE_MESSAGE string!");
    TEST_FAIL("This should not be reached");
    EXPECT_ABORT_END

    ignored = Unity.CurrentTestIgnored;
    Unity.CurrentTestIgnored = 0;

    TEST_ASSERT(ignored);
}
Esempio n. 29
0
TEST(LeakDetection, DetectsLeak)
{
#ifndef USING_OUTPUT_SPY
    TEST_IGNORE_MESSAGE("Build with '-D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar' to enable tests");
#else
    void* m = malloc(10);
    TEST_ASSERT_NOT_NULL(m);
    UnityOutputCharSpy_Enable(1);
    EXPECT_ABORT_BEGIN
    UnityMalloc_EndTest();
    EXPECT_ABORT_END
    UnityOutputCharSpy_Enable(0);
    Unity.CurrentTestFailed = 0;
    CHECK(strstr(UnityOutputCharSpy_Get(), "This test leaks!"));
    free(m);
#endif
}
Esempio n. 30
0
void
tearDown(void) {
#ifdef HYBRID
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  datastore_interp_state_t state = DATASTORE_INTERP_STATE_AUTO_COMMIT;
  char *str = NULL;

  /* bridge destroy cmd.*/
  TEST_BRIDGE_DESTROY(ret, &interp, state, &tbl, &ds, str,
                      "br0", "cha1", "c1",
                      "test_if01", "test_port01");

  /* destroy interp. */
  INTERP_DESTROY(NULL, interp, tbl, ds, destroy);
#else /* HYBRID */
  TEST_IGNORE_MESSAGE("HYBRID is not defined.");
#endif /* HYBRID */
}