Example #1
0
END_TEST

START_TEST (rdrand_step_32_native)
{
  unsigned char dst[DEST_SIZE] = {0};
  ck_assert_int_eq (rdrand32_step_native((uint32_t *)&dst),RDRAND_SUCCESS);
  
  // test if it wrote just into the place it should
  ck_assert(test_zeros(dst, DEST_SIZE, 4, DEST_SIZE));
  
  // test if it wrote something (rarely can fail)
  TEST_BYTES_PRINT=0;
  ck_assert_msg(test_zeros(dst, DEST_SIZE, 0, 4)==FALSE, 
		"This test can rarely fail if rdrand generates just all zeros. \
		Try it once more to be sure.\n");
  TEST_BYTES_PRINT=1;
}
Example #2
0
END_TEST



START_TEST (array_reseed_skip_64)
{
  unsigned int size=ARRAY_SIZE-1;
  unsigned int offset=16;
  
  unsigned int multiplier=8; // 1 - 8bit, 2 - 64bit, 4 - 32bit, ...
  
  /* Generate one size */
  {{{
	  unsigned char dst[ARRAY_SIZE] = {0};
	  ck_assert_int_eq (rdrand_get_uint64_array_reseed_skip((uint64_t *)&dst, size/multiplier, RETRY_LIMIT), size/multiplier);
	  // test if it wrote just into the place it should
	  ck_assert(test_zeros(dst, ARRAY_SIZE, size, ARRAY_SIZE));
	  // test if it wrote something (rarely can fail)
	  ck_assert(test_ones(dst, ARRAY_SIZE, 0, size));
  }}}	
  
  /* Generate half size */
  {{{
	  unsigned char dst[ARRAY_SIZE] = {0};
	  ck_assert_int_eq (rdrand_get_uint64_array_reseed_skip((uint64_t *)&dst, size/(2*multiplier), RETRY_LIMIT), size/(2*multiplier));
	  // test if it wrote just into the place it should
	  ck_assert(test_zeros(dst, ARRAY_SIZE, size/2, ARRAY_SIZE));
	  // test if it wrote something (rarely can fail)
	  ck_assert(test_ones(dst, ARRAY_SIZE, 0, size/2));
  }}}	
  
  /* Generate half size with offset */
  {{{
	  unsigned char dst[ARRAY_SIZE] = {0};
	  ck_assert_int_eq (rdrand_get_uint64_array_reseed_skip((uint64_t *)&dst+offset/multiplier, size/(2*multiplier), RETRY_LIMIT), size/(2*multiplier));
	  // test if it wrote just into the place it should
	  ck_assert(test_zeros(dst, ARRAY_SIZE, size/2+offset, ARRAY_SIZE));
	  // test if it wrote just into the place it should
	  ck_assert(test_zeros(dst, ARRAY_SIZE, 0, offset));
	  // test if it wrote something (rarely can fail)
	  ck_assert(test_ones(dst, ARRAY_SIZE, offset, size/2));
  }}}
}
Example #3
0
/** ******************************************************************/
void rdrand_retry_16_test(int retry)
{
	 unsigned char dst[DEST_SIZE] = {0};
  ck_assert_int_eq (rdrand_get_uint16_retry((uint16_t *)&dst,retry),RDRAND_SUCCESS);
  
  // test if it wrote just into the place it should
  ck_assert(test_zeros(dst, DEST_SIZE, 2, DEST_SIZE));
  
  // test if it wrote something (rarely can fail)
  ck_assert(test_ones(dst, DEST_SIZE, 0, 2));
}
Example #4
0
END_TEST

START_TEST (rdrand_step_32_stub)
{
  unsigned char dst[DEST_SIZE] = {0};
  ck_assert_int_eq (rdrand32_step((uint32_t *)&dst),RDRAND_SUCCESS);
  
  // test if it wrote just into the place it should
  ck_assert(test_zeros(dst, DEST_SIZE, 4, DEST_SIZE));
  
  // test if it set all to 1
  ck_assert(test_ones(dst, DEST_SIZE, 0, 4));
}
Example #5
0
int
main(int argc, char *argv[])
{

	printf("1..15\n");

	/* Test csqrt() */
	t_csqrt = _csqrt;

	test_finite();
	printf("ok 1 - csqrt\n");

	test_zeros();
	printf("ok 2 - csqrt\n");

	test_infinities();
	printf("ok 3 - csqrt\n");

	test_nans();
	printf("ok 4 - csqrt\n");

	test_overflow(DBL_MAX_EXP);
	printf("ok 5 - csqrt\n");

	/* Now test csqrtf() */
	t_csqrt = _csqrtf;

	test_finite();
	printf("ok 6 - csqrt\n");

	test_zeros();
	printf("ok 7 - csqrt\n");

	test_infinities();
	printf("ok 8 - csqrt\n");

	test_nans();
	printf("ok 9 - csqrt\n");

	test_overflow(FLT_MAX_EXP);
	printf("ok 10 - csqrt\n");

	/* Now test csqrtl() */
	t_csqrt = csqrtl;

	test_finite();
	printf("ok 11 - csqrt\n");

	test_zeros();
	printf("ok 12 - csqrt\n");

	test_infinities();
	printf("ok 13 - csqrt\n");

	test_nans();
	printf("ok 14 - csqrt\n");

	test_overflow(LDBL_MAX_EXP);
	printf("ok 15 - csqrt\n");

	return (0);
}