예제 #1
0
/*
 * inf_connect_close() Test the ndmp NDMP_CONNECT_CLOSE interface for
 * different error condition. This message is used when the client wants to
 * close the NDMP connection. The DMA SHOULD send this message before
 * shutting down the TCP/IP connection. For reasons of backward
 * compatibility, it is guaranteed that the parameters of this message will
 * not change in any future release. The parameters MUST not change since
 * this message is sent prior to protocol version negotiation.
 *
 * Arguments : error - Error condition to test. host_details - Information about
 * the host. outfile - log file.
 *
 * Return : 0 - Success 1 - Error
 */
int
inf_connect_close(host_info * host_details, FILE * outfile)
{
	conn_handle conn;
	ndmp_connect_open_reply *reply = NULL;
	ndmp_connect_client_auth_reply *reply_ca = NULL;

	(void) ndmp_fprintf(outfile,
		"Test case name : ndmp_connect_close\n");
	client_connect_open(host_details, &conn, &reply, outfile);
	if (reply->error != NDMP_NO_ERR) {
		(void) ndmp_fprintf(outfile, "inf_connect_close: "
			"Not able to open connection \n");
		print_test_result(1, outfile);
		return (1);
	}
	client_connect_authorize(host_details, &conn, &reply_ca, outfile);
	if (reply_ca->error != NDMP_NO_ERR) {
		(void) ndmp_fprintf(outfile, "inf_connect_close: "
			"Not able to authorize connection \n");
		print_test_result(1, outfile);
		return (1);
	}
	print_test_result(client_connect_close(&conn, outfile), outfile);
	return (0);
}
예제 #2
0
/*
 * inf_connect_client_auth() Test the ndmp NDMP_CONNECT_CLIENT_AUTH interface
 * for different error condition. This request authenticates the DMA to a
 * NDMP Server. Successful DMA authentication MUST occur prior to processing
 * most NDMP requests. Requests that do not require DMA authentication are
 * limited to NDMP_CONNECT_OPEN, NDMP_CONNECT_CLOSE,
 * NDMP_CONFIG_GET_SERVER_INFO, NDMP_CONFIG_GET_AUTH_ATTR and
 * NDMP_CONNECT_CLIENT_AUTH. Any other request received prior to successful
 * DMA authentication will result in a NDMP_NOT_AUTHORIZED reply error.
 *
 * Arguments : error - Error condition to test. host_details - Information about
 * the host. outfile - log file.
 *
 * Return : 0 - Success 1 - Error
 */
int
inf_connect_client_auth(ndmp_error error, host_info * host_details,
			FILE * outfile)
{
	conn_handle conn;
	ndmp_connect_open_reply *reply = NULL;
	ndmp_connect_client_auth_reply *reply_ca = NULL;

	(void) ndmp_fprintf(outfile,
		"Test case name : ndmp_connect_client_auth\n");
	(void) ndmp_fprintf(outfile,
		"Error condition : %s\n", ndmpErrorCodeToStr(error));
	client_connect_open(host_details, &conn, &reply, outfile);
	if (reply->error != NDMP_NO_ERR) {
		(void) ndmp_dprintf(outfile, "inf_connect_client_auth: "
			"Not able to open connection \n");
		print_test_result(1, outfile);
		return (1);
	}
	client_connect_authorize(host_details, &conn, &reply_ca, outfile);
	if (reply_ca != NULL && reply_ca->error == error) {
		print_test_result(0, outfile);
	} else {
		print_test_result(1, outfile);
	}
	close_connection(&conn, outfile);
	return (0);
}
예제 #3
0
파일: test_erf.hpp 프로젝트: CASL/vera_tpls
void do_test_erf(const T& data, const char* type_name, const char* test_name)
{
   typedef typename T::value_type row_type;
   typedef typename row_type::value_type value_type;

   typedef value_type (*pg)(value_type);
#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
   pg funcp = boost::math::erf<value_type>;
#else
   pg funcp = boost::math::erf;
#endif

   boost::math::tools::test_result<value_type> result;

   std::cout << "Testing " << test_name << " with type " << type_name
      << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";

   //
   // test erf against data:
   //
   result = boost::math::tools::test(
      data,
      bind_func(funcp, 0),
      extract_result(1));
   handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::erf", test_name);
#ifdef TEST_OTHER
   if(::boost::is_floating_point<value_type>::value){
      funcp = other::erf;
      result = boost::math::tools::test(
         data,
         bind_func(funcp, 0),
         extract_result(1));
      print_test_result(result, data[result.worst()], result.worst(), type_name, "other::erf");
   }
#endif
   //
   // test erfc against data:
   //
#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
   funcp = boost::math::erfc<value_type>;
#else
   funcp = boost::math::erfc;
#endif
   result = boost::math::tools::test(
      data,
      bind_func(funcp, 0),
      extract_result(2));
   handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::erfc", test_name);
#ifdef TEST_OTHER
   if(::boost::is_floating_point<value_type>::value){
      funcp = other::erfc;
      result = boost::math::tools::test(
         data,
         bind(funcp, 0),
         extract_result(2));
      print_test_result(result, data[result.worst()], result.worst(), type_name, "other::erfc");
   }
#endif
   std::cout << std::endl;
}
예제 #4
0
int
main (int argc, char *const *argv)
{
  unsigned int errorCount = 0;
  const char *aes256_sha_tlsv1   = "AES256-SHA";
  (void)argc;   /* Unused. Silent compiler warning. */

#ifdef MHD_HTTPS_REQUIRE_GRYPT
  gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
#ifdef GCRYCTL_INITIALIZATION_FINISHED
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
#endif /* MHD_HTTPS_REQUIRE_GRYPT */
  if (!testsuite_curl_global_init ())
    return 99;
  if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
    {
      fprintf (stderr, "Curl does not support SSL.  Cannot run the test.\n");
      curl_global_cleanup ();
      return 77;
    }

  if (curl_uses_nss_ssl() == 0)
    {
      aes256_sha_tlsv1 = "rsa_aes_256_sha";
    }

  errorCount +=
    test_secure_get (NULL, aes256_sha_tlsv1, CURL_SSLVERSION_TLSv1);
  print_test_result (errorCount, argv[0]);

  curl_global_cleanup ();

  return errorCount != 0 ? 1 : 0;
}
예제 #5
0
int
main (int argc, char *const *argv)
{
  unsigned int errorCount = 0;
  const char *aes256_sha_tlsv1   = "AES256-SHA";
  const char *des_cbc3_sha_tlsv1 = "DES-CBC3-SHA";

  gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
#ifdef GCRYCTL_INITIALIZATION_FINISHED
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
  if (0 != curl_global_init (CURL_GLOBAL_ALL))
    {
      fprintf (stderr, "Error: %s\n", strerror (errno));
      return -1;
    }

  if (curl_uses_nss_ssl() == 0)
    {
      aes256_sha_tlsv1 = "rsa_aes_256_sha";
      des_cbc3_sha_tlsv1 = "rsa_aes_128_sha";
    }

  errorCount +=
    test_secure_get (NULL, aes256_sha_tlsv1, CURL_SSLVERSION_TLSv1);
  errorCount +=
    test_cipher_option (NULL, des_cbc3_sha_tlsv1, CURL_SSLVERSION_TLSv1);
  print_test_result (errorCount, argv[0]);

  curl_global_cleanup ();

  return errorCount != 0;
}
예제 #6
0
파일: pwrite02.c 프로젝트: MohdVara/ltp
static void test_ebadf1(void)
{
	int fd = -1;

	TEST(pwrite(fd, write_buf, K1, 0));

	print_test_result(errno, EBADF);
}
예제 #7
0
/*
 * inf_connect_open() Test the ndmp connect open interface for different
 * error condition. This message negotiates the protocol version to be used
 * between the DMA and NDMP Server. This message is OPTIONAL if the DMA
 * agrees to the protocol version specified in the
 * NDMP_NOTIFY_CONNECTION_STATUS message. If sent, it MUST be the first
 * message type sent by the DMA. If the suggested protocol version is not
 * supported on the NDMP Server, an NDMP_ILLEGAL_ARGS_ERR MUST be returned.
 *
 * Arguments : error - Error condition to test ndmp_ver - NDMP version to test.
 * Default is 4 outfile - log file
 *
 * Return : 0 - Success 1 - Error
 */
int
inf_connect_open(ndmp_error error, host_info * host_details, FILE * outfile)
{
	conn_handle conn;
	ndmp_connect_open_reply *reply = NULL;

	(void) ndmp_fprintf(outfile,
		"Test case name : ndmp_connect_open\n");
	(void) ndmp_fprintf(outfile,
		"Error condition : %s\n", ndmpErrorCodeToStr(error));
	if (error == NDMP_ILLEGAL_ARGS_ERR) {
		host_details->protocol_version = -1;
	}
	client_connect_open(host_details, &conn, &reply, outfile);
	if (error == NDMP_ILLEGAL_STATE_ERR) {
		ndmp_connect_client_auth_reply *reply_ca = NULL;
		client_connect_authorize(host_details,
						&conn, &reply_ca, outfile);
		if (reply_ca->error != NDMP_NO_ERR) {
			(void) ndmp_fprintf(outfile, "inf_connect_close: "
				"Not able to authorize connection \n");
			print_test_result(1, outfile);
			return (1);
		}
		if (data_listen_core(NDMP_NO_ERR, NDMP_ADDR_LOCAL,
			NULL, outfile, &conn)) {
			(void) ndmp_fprintf(outfile, "inf_connect_close: "
				"Not able to do data listen\n");
		}
		if (data_connect_core(NDMP_NO_ERR, NDMP_ADDR_LOCAL,
			NULL, outfile, &conn)) {
			(void) ndmp_fprintf(outfile, "inf_connect_close: "
				"Not able to do data connect\n");
		}
		client_connect_open(host_details, &conn, &reply, outfile);
	}
	if (reply->error == error)
		print_test_result(0, outfile);
	else
		print_test_result(1, outfile);
	close_connection(&conn, outfile);
	return (0);
}
예제 #8
0
void post_executor_test(int time_taken)
{
    test_t * test = test_current(g_test_runner);
    test->time_taken = time_taken;
    if (test->is_failure)
    {
        g_test_runner->total_success--;
        g_test_runner->total_failures++;
    }
    print_test_result();
}
예제 #9
0
/*
 * inf_connect_server_auth() Test the ndmp NDMP_CONNECT_SERVER_AUTH interface
 * for different error condition. This optional request is used by the DMA to
 * force the NDMP Server to authenticate itself. The DMA may use this request
 * when there is a security requirement to validate the sever identity. A DMA
 * MUST authenticate itself to the server using the NDMP_CONNECT_CLIENT_AUTH
 * prior to issuing this request.
 *
 * Arguments : error - Error condition to test. host_details - Information about
 * the host. ndmp_ver - NDMP version to test. Default is 4. challenge -
 * Challenge string. outfile - log file.
 *
 * Return : 0 - Success 1 - Error
 */
int
inf_connect_server_auth(ndmp_error error, host_info * host_details,
			FILE * outfile)
{
	conn_handle conn;
	char *challenge = "bad";
	ndmp_connect_open_reply *reply = NULL;
	ndmp_connect_client_auth_reply *reply_ca = NULL;
	ndmp_connect_server_auth_reply *reply_sa = NULL;

	(void) ndmp_fprintf(outfile,
		"Test case name : ndmp_connect_server_auth\n");
	(void) ndmp_fprintf(outfile,
		"Error condition : %s\n", ndmpErrorCodeToStr(error));
	client_connect_open(host_details, &conn, &reply, outfile);
	if (reply->error != NDMP_NO_ERR) {
		(void) ndmp_dprintf(outfile, "inf_connect_server_auth: "
			"Not able to open connection \n");
		print_test_result(1, outfile);
		return (1);
	}
	client_connect_authorize(host_details, &conn, &reply_ca, outfile);
	if (reply_ca->error != NDMP_NO_ERR) {
		(void) ndmp_dprintf(outfile, "inf_connect_server_auth: "
			"Not able to authorize connection \n");
		print_test_result(1, outfile);
		return (1);
	}
	if (error == NDMP_ILLEGAL_ARGS_ERR &&
		host_details->server_challenge == NULL) {
		strcpy(host_details->server_challenge, challenge);
	}
	server_connect_auth(host_details, &conn, &reply_sa, outfile);
	if (reply_sa != NULL && reply_sa->error == error) {
		print_test_result(0, outfile);
	} else {
		print_test_result(1, outfile);
	}
	close_connection(&conn, outfile);
	return (0);
}
예제 #10
0
파일: pwrite02.c 프로젝트: MohdVara/ltp
static void test_ebadf2(void)
{
	int fd;

	fd = SAFE_OPEN(cleanup, TEMPFILE, O_RDONLY | O_CREAT, 0666);

	TEST(pwrite(fd, write_buf, K1, 0));

	print_test_result(errno, EBADF);

	SAFE_CLOSE(cleanup, fd);
}
예제 #11
0
int main() {
  PFC pfc(AES_SECURITY);  // initialise pairing-friendly curve
  miracl *mip=get_mip();  // get handle on mip (Miracl Instance Pointer)

  mip->IOBASE=10;

  std::string test_name;
  int result = runTests(test_name);
  print_test_result(result,test_name);

  return 0;
}
예제 #12
0
파일: pwrite02.c 프로젝트: MohdVara/ltp
static void test_einval(void)
{
	int fd;

	fd = SAFE_OPEN(cleanup, TEMPFILE, O_RDWR | O_CREAT, 0666);

	/* the specified offset was invalid */
	TEST(pwrite(fd, write_buf, K1, -1));

	print_test_result(errno, EINVAL);

	SAFE_CLOSE(cleanup, fd);
}
예제 #13
0
파일: pwrite02.c 프로젝트: MohdVara/ltp
static void test_espipe(void)
{
	int pipe_fds[2];

	SAFE_PIPE(cleanup, pipe_fds);

	TEST(pwrite(pipe_fds[1], write_buf, K1, 0));

	print_test_result(errno, ESPIPE);

	SAFE_CLOSE(cleanup, pipe_fds[0]);
	SAFE_CLOSE(cleanup, pipe_fds[1]);
}
예제 #14
0
파일: pwrite02.c 프로젝트: MohdVara/ltp
static void test_efault(void)
{
	int fd;
	char *buf = sbrk(0);

	fd = SAFE_OPEN(cleanup, TEMPFILE, O_RDWR | O_CREAT, 0666);

	TEST(pwrite(fd, buf, K1, 0));

	print_test_result(errno, EFAULT);

	SAFE_CLOSE(cleanup, fd);
}
예제 #15
0
파일: getdents02.c 프로젝트: GOEUM/ltp
static void test_ebadf(void)
{
	int fd = -5;
	struct linux_dirent64 dirp64;
	struct linux_dirent dirp;

	if (longsyscall)
		getdents64(fd, &dirp64, sizeof(dirp64));
	else
		getdents(fd, &dirp, sizeof(dirp));

	print_test_result(errno, EBADF);
}
예제 #16
0
int main() {
  PFC pfc(AES_SECURITY);  // initialise pairing-friendly curve
  miracl *mip=get_mip();  // get handle on mip (Miracl Instance Pointer)

  mip->IOBASE=10;

  time_t seed;            // crude randomisation. Check if this is the version that is crypto-secure.
  time(&seed);
  irand((long)seed);

  std::string test_name = "Test BLAccessPolicy";
  int result = runTests(pfc);
  print_test_result(result,test_name);

  return 0;
}
예제 #17
0
int
main (int argc, char *const *argv)
{
  int errorCount = 0;;
  struct MHD_Daemon *d;
  gnutls_session_t session;
  gnutls_datum_t key;
  gnutls_datum_t cert;
  gnutls_certificate_credentials_t xcred;


  gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
#ifdef GCRYCTL_INITIALIZATION_FINISHED
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
  gnutls_global_init ();
  gnutls_global_set_log_level (11);

  d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
                        MHD_USE_DEBUG, DEAMON_TEST_PORT,
                        NULL, NULL, &http_dummy_ahc, NULL,
                        MHD_OPTION_CONNECTION_TIMEOUT, TIME_OUT,
                        MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
                        MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
                        MHD_OPTION_END);

  if (d == NULL)
    {
      fprintf (stderr, MHD_E_SERVER_INIT);
      return -1;
    }

  if (0 != setup_session (&session, &key, &cert, &xcred))
    {
      fprintf (stderr, "failed to setup session\n");
      return 1;
    }
  errorCount += test_tls_session_time_out (session);
  teardown_session (session, &key, &cert, xcred);

  print_test_result (errorCount, argv[0]);

  MHD_stop_daemon (d);
  gnutls_global_deinit ();

  return errorCount != 0;
}
예제 #18
0
파일: getdents02.c 프로젝트: GOEUM/ltp
static void test_einval(void)
{
	int fd;
	char buf[1];

	fd = SAFE_OPEN(cleanup, ".", O_RDONLY);

	/* Pass one byte long buffer. The result should be EINVAL */
	if (longsyscall)
		getdents64(fd, (void *)buf, sizeof(buf));
	else
		getdents(fd, (void *)buf, sizeof(buf));

	print_test_result(errno, EINVAL);

	SAFE_CLOSE(cleanup, fd);
}
예제 #19
0
void do_test_cyl_bessel_i(const T& data, const char* type_name, const char* test_name)
{
   typedef typename T::value_type row_type;
   typedef Real                   value_type;

   typedef value_type (*pg)(value_type, value_type);
#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
   pg funcp = boost::math::cyl_bessel_i<value_type, value_type>;
#else
   pg funcp = boost::math::cyl_bessel_i;
#endif

   boost::math::tools::test_result<value_type> result;

   std::cout << "Testing " << test_name << " with type " << type_name
      << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";

   //
   // test cyl_bessel_i against data:
   //
   result = boost::math::tools::test_hetero<Real>(
      data, 
      bind_func<Real>(funcp, 0, 1), 
      extract_result<Real>(2));
   handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_bessel_i", test_name);
   std::cout << std::endl;

#ifdef TEST_OTHER
   if(boost::is_floating_point<value_type>::value)
   {
      funcp = other::cyl_bessel_i;

      //
      // test other::cyl_bessel_i against data:
      //
      result = boost::math::tools::test(
         data, 
         boost::lambda::bind(funcp, 
            boost::lambda::ret<value_type>(boost::lambda::_1[0]),
            boost::lambda::ret<value_type>(boost::lambda::_1[1])), 
         boost::lambda::ret<value_type>(boost::lambda::_1[2]));
      print_test_result(result, data[result.worst()], result.worst(), type_name, "other::cyl_bessel_i");
      std::cout << std::endl;
   }
#endif
}
예제 #20
0
int
main (int argc, char *const *argv)
{
  unsigned int errorCount = 0;

  if (0 != curl_global_init (CURL_GLOBAL_ALL))
    {
      fprintf (stderr, "Error (code: %u)\n", errorCount);
      return -1;
    }
  errorCount += test_query_session ();
  print_test_result (errorCount, argv[0]);
  curl_global_cleanup ();
  if (errorCount > 0)
    fprintf (stderr, "Error (code: %u)\n", errorCount);
  return errorCount;
}
예제 #21
0
파일: getdents02.c 프로젝트: GOEUM/ltp
static void test_enotdir(void)
{
	int fd;
	struct linux_dirent64 dir64;
	struct linux_dirent dir;

	fd = SAFE_OPEN(cleanup, "test", O_CREAT | O_RDWR);

	if (longsyscall)
		getdents64(fd, &dir64, sizeof(dir64));
	else
		getdents(fd, &dir, sizeof(dir));

	print_test_result(errno, ENOTDIR);

	SAFE_CLOSE(cleanup, fd);
}
예제 #22
0
int
main (int argc, char *const *argv)
{
  unsigned int errorCount = 0;
  FILE *cert;

  gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
#ifdef GCRYCTL_INITIALIZATION_FINISHED
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
  if (0 != curl_global_init (CURL_GLOBAL_ALL))
    {
      fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__,
               __FUNCTION__);
      return -1;
    }
  if ((cert = setup_ca_cert ()) == NULL)
    {
      fprintf (stderr, MHD_E_TEST_FILE_CREAT);
      return -1;
    }

  const char *aes256_sha = "AES256-SHA";
  if (curl_uses_nss_ssl() == 0)
    {
      aes256_sha = "rsa_aes_256_sha";
    }
  
  errorCount +=
    test_concurent_daemon_pair (NULL, aes256_sha, CURL_SSLVERSION_SSLv3);

  print_test_result (errorCount, "concurent_daemon_pair");

  curl_global_cleanup ();
  fclose (cert);
  if (0 != remove (ca_cert_file_name))
    fprintf (stderr,
	     "Failed to remove `%s'\n",
	     ca_cert_file_name);
  return errorCount != 0;
}
예제 #23
0
int
main (int argc, char *const *argv)
{
  unsigned int errorCount = 0;

  gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
#ifdef GCRYCTL_INITIALIZATION_FINISHED
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
  if (setup_ca_cert () == NULL)
    {
      fprintf (stderr, MHD_E_TEST_FILE_CREAT);
      return -1;
    }

  if (0 != curl_global_init (CURL_GLOBAL_ALL))
    {
      fprintf (stderr, "Error (code: %u)\n", errorCount);
      return -1;
    }

  char *aes256_sha = "AES256-SHA";
  if (curl_uses_nss_ssl() == 0)
    {
      aes256_sha = "rsa_aes_256_sha";
    }

  errorCount +=
    test_secure_get (NULL, aes256_sha, CURL_SSLVERSION_TLSv1);

  print_test_result (errorCount, argv[0]);

  curl_global_cleanup ();
  if (0 != remove (ca_cert_file_name))
    fprintf (stderr,
	     "Failed to remove `%s'\n",
	     ca_cert_file_name);
  return errorCount != 0;
}
예제 #24
0
int
main (int argc, char *const *argv)
{
  int errorCount = 0;;
  struct MHD_Daemon *d;
  MHD_gtls_session_t session;
  MHD_gnutls_datum_t key;
  MHD_gnutls_datum_t cert;
  MHD_gtls_cert_credentials_t xcred;

  MHD__gnutls_global_init ();
  MHD_gtls_global_set_log_level (11);

  d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
                        MHD_USE_DEBUG, DEAMON_TEST_PORT,
                        NULL, NULL, &http_dummy_ahc, NULL,
                        MHD_OPTION_CONNECTION_TIMEOUT, TIME_OUT,
                        MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
                        MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
                        MHD_OPTION_END);

  if (d == NULL)
    {
      fprintf (stderr, MHD_E_SERVER_INIT);
      return -1;
    }

  setup_timeout_test (&session, &key, &cert, &xcred);
  errorCount += test_tls_session_time_out (session);
  teardown_timeout_test (session, &key, &cert, xcred);

  print_test_result (errorCount, argv[0]);

  MHD_stop_daemon (d);
  MHD__gnutls_global_deinit ();

  return errorCount != 0;
}
예제 #25
0
파일: getdents02.c 프로젝트: GOEUM/ltp
static void test_enoent(void)
{
	int fd;
	struct linux_dirent64 dir64;
	struct linux_dirent dir;

	SAFE_MKDIR(cleanup, TEST_DIR, DIR_MODE);

	fd = SAFE_OPEN(cleanup, TEST_DIR, O_DIRECTORY);
	if (rmdir(TEST_DIR) == -1) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "rmdir(%s) failed", TEST_DIR);
	}

	if (longsyscall)
		getdents64(fd, &dir64, sizeof(dir64));
	else
		getdents(fd, &dir, sizeof(dir));

	print_test_result(errno, ENOENT);

	SAFE_CLOSE(cleanup, fd);
}
예제 #26
0
int main() {
  //  miracl *mip = mirsys(5000,0); // C version: this is necessary to get the MIRACL functioning, which means that then I can call Bigs and so forth.
  // Miracl precision(5,0); // C++ version for the above, together with the next line
  // miracl* mip = &precision;

  // The constructor of PFC (in bn_pair.cpp) already invokes mirsys and initializes the mip pointer.
  // Because of this, I don't do that explicitly here.
  // It also sets the base to 16, but I include that here for clarity. One should not have to read the code of library classes to understand this code

  PFC pfc(AES_SECURITY);  // initialise pairing-friendly curve
  miracl *mip=get_mip();  // get handle on mip (Miracl Instance Pointer)

  mip->IOBASE=16;

  time_t seed;            // crude randomisation. Check if this is the version that is crypto-secure.
  time(&seed);
  irand((long)seed);

  DEBUG("Calling first constructor");
  ShamirTest tests(pfc); 
  int result = tests.runTests();
  print_test_result(result,tests.name());
  return 0;
}
예제 #27
0
int
main (int argc, char *const *argv)
{
  int i, errorCount = 0;
  FILE *test_fd;
  struct MHD_Daemon *d;
  gnutls_session_t session;
  gnutls_datum_t key;
  gnutls_datum_t cert;
  gnutls_certificate_credentials_t xcred;

  const int ext_arr[] = {
    GNUTLS_EXTENSION_SERVER_NAME,
    -1
  };

  gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
#ifdef GCRYCTL_INITIALIZATION_FINISHED
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
  MHD_gtls_global_set_log_level (11);

  if ((test_fd = setup_test_file ()) == NULL)
    {
      fprintf (stderr, MHD_E_TEST_FILE_CREAT);
      return -1;
    }

  if (0 != curl_global_init (CURL_GLOBAL_ALL))
    {
      fprintf (stderr, "Error: %s\n", strerror (errno));
      return -1;
    }

  d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
                        MHD_USE_DEBUG, DEAMON_TEST_PORT,
                        NULL, NULL, &http_ahc, NULL,
                        MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
                        MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
                        MHD_OPTION_END);

  if (d == NULL)
    {
      fprintf (stderr, "%s\n", MHD_E_SERVER_INIT);
      return -1;
    }

  i = 0;
  setup_session (&session, &key, &cert, &xcred);
  errorCount += test_hello_extension (session, ext_arr[i], 1, 16);
  teardown_session (session, &key, &cert, xcred);
#if 1
  i = 0;
  while (ext_arr[i] != -1)
    {
      setup_session (&session, &key, &cert, &xcred);
      errorCount += test_hello_extension (session, ext_arr[i], 1, 16);
      teardown_session (session, &key, &cert, xcred);

      setup_session (&session, &key, &cert, &xcred);
      errorCount += test_hello_extension (session, ext_arr[i], 3, 8);
      teardown_session (session, &key, &cert, xcred);

      /* this test specifically tests the issue raised in CVE-2008-1948 */
      setup_session (&session, &key, &cert, &xcred);
      errorCount += test_hello_extension (session, ext_arr[i], 6, 0);
      teardown_session (session, &key, &cert, xcred);
      i++;
    }
#endif

  print_test_result (errorCount, argv[0]);

  MHD_stop_daemon (d);

  curl_global_cleanup ();
  fclose (test_fd);

  return errorCount;
}
예제 #28
0
void
packet_buffer_test()
{
	test_result res = test_result::pass;

/*
	if (sizeof(packet_buffer_ring_descriptor) == 16) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("sizeof(packet_buffer_ring_descriptor) == 16", res);
*/

	utf8str s;

	packet_buffer *p = new packet_buffer;

	s = "p = 0x";
	s.append_hex64((uint64_t)p, 16);
	print_test_result(s, res);

	s = "i = 0x";
	s.append_hex64(p->initial_head_address(), 16);
	print_test_result(s, res);

	s = "x = 0x";
	s.append_hex64((uint64_t)packet_buffer_from_initial_head_address(p->initial_head_address()), 16);
	print_test_result(s, res);

	if (packet_buffer_from_initial_head_address(p->initial_head_address()) == p) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("packet_buffer_from_initial_head_address", res);

	uint8_t *initial_head = p->head();
	uint8_t *initial_tail = p->tail();
	//uint64_t initial_size = p->size();

	s = "hr = 0x";
	s.append_hex64(p->headroom(), 16);
	print_test_result(s, test_result::pass);

	s = "tr = 0x";
	s.append_hex64(p->tailroom(), 16);
	print_test_result(s, test_result::pass);

	uint8_t buf[100];

	p->prepend(buf, 100);

	if (p->size() == 100) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("prepend: size", res);

	if (p->head() == (initial_head - 100)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("prepend: head", res);

	if (p->tail() == initial_tail) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("prepend: tail", res);

	p->append(buf, 100);

	if (p->size() == 200) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("append: size", res);

	if (p->head() == (initial_head - 100)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("append: head", res);

	if (p->tail() == (initial_tail + 100)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("append: tail", res);

	p->head_move(-10);

	if (p->size() == 210) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("head_move-: size", res);

	if (p->head() == (initial_head - 110)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("head_move-: head", res);

	if (p->tail() == (initial_tail + 100)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("head_move-: tail", res);

	p->head_move(10);

	if (p->size() == 200) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("head_move+: size", res);

	if (p->head() == (initial_head - 100)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("head_move+: head", res);

	if (p->tail() == (initial_tail + 100)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("head_move+: tail", res);

	p->tail_move(-10);

	if (p->size() == 190) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("tail_move-: size", res);

	if (p->head() == (initial_head - 100)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("tail_move-: head", res);

	if (p->tail() == (initial_tail + 90)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("tail_move-: tail", res);

	p->tail_move(10);

	if (p->size() == 200) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("tail_move+: size", res);

	if (p->head() == (initial_head - 100)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("tail_move+: head", res);

	if (p->tail() == (initial_tail + 100)) {
		res = test_result::pass;
	} else {
		res = test_result::fail;
	}
	print_test_result("tail_move+: tail", res);

	packet_buffer *parr[1000];
	for (int i = 0; i < 1000; ++i) {
		parr[i] = new packet_buffer;
		uint64_t iha = parr[i]->initial_head_address();
		for (int j = iha - 100; j < iha + 1100; ++j) {
			packet_buffer *t = packet_buffer::container_of(j);
			if (t != parr[i]) {
				utf8str s;
				s += "i = ";
				s.append_sint64(i, 0);
				s += " j = ";
				s.append_sint64(j, 0);
				s += " t = ";
				s.append_hex64((uint64_t)t, 16);
				s += " parr[i] = ";
				s.append_hex64((uint64_t)parr[i], 16);
				print_test_result(s, test_result::fail);
			}
		}
	}
	for (int i = 0; i < 1000; ++i) {
		delete parr[i];
	}
	delete p;

}
예제 #29
0
int
main (int argc, char *const *argv)
{
  int errorCount = 0;;
  struct MHD_Daemon *d;
  gnutls_session_t session;
  gnutls_datum_t key;
  gnutls_datum_t cert;
  gnutls_certificate_credentials_t xcred;
  int port;
  (void)argc;   /* Unused. Silent compiler warning. */

  if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
    port = 0;
  else
    port = 3070;

#ifdef MHD_HTTPS_REQUIRE_GRYPT
  gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
#ifdef GCRYCTL_INITIALIZATION_FINISHED
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
#endif /* MHD_HTTPS_REQUIRE_GRYPT */
  gnutls_global_init ();
  gnutls_global_set_log_level (11);

  d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS |
                        MHD_USE_ERROR_LOG, port,
                        NULL, NULL, &http_dummy_ahc, NULL,
                        MHD_OPTION_CONNECTION_TIMEOUT, TIME_OUT,
                        MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
                        MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
                        MHD_OPTION_END);

  if (NULL == d)
    {
      fprintf (stderr, MHD_E_SERVER_INIT);
      return -1;
    }
  if (0 == port)
    {
      const union MHD_DaemonInfo *dinfo;
      dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
      if (NULL == dinfo || 0 == dinfo->port)
        { MHD_stop_daemon (d); return -1; }
      port = (int)dinfo->port;
    }

  if (0 != setup_session (&session, &key, &cert, &xcred))
    {
      fprintf (stderr, "failed to setup session\n");
      return 1;
    }
  errorCount += test_tls_session_time_out (session, port);
  teardown_session (session, &key, &cert, xcred);

  print_test_result (errorCount, argv[0]);

  MHD_stop_daemon (d);
  gnutls_global_deinit ();

  return errorCount != 0 ? 1 : 0;
}
예제 #30
0
void do_test_legendre_p(const T& data, const char* type_name, const char* test_name)
{
   typedef typename T::value_type row_type;
   typedef typename row_type::value_type value_type;

   typedef value_type (*pg)(int, value_type);
#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
   pg funcp = boost::math::legendre_p<value_type>;
#else
   pg funcp = boost::math::legendre_p;
#endif

   boost::math::tools::test_result<value_type> result;

   std::cout << "Testing " << test_name << " with type " << type_name
      << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";

   //
   // test legendre_p against data:
   //
   result = boost::math::tools::test(
      data,
      bind_func_int1(funcp, 0, 1),
      extract_result(2));
   handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::legendre_p", test_name);
#ifdef TEST_OTHER
   if(::boost::is_floating_point<value_type>::value){
      funcp = other::legendre_p;
   result = boost::math::tools::test(
      data,
      bind_func_int1(funcp, 0, 1),
      extract_result(2));
      print_test_result(result, data[result.worst()], result.worst(), type_name, "other::legendre_p");
   }
#endif

   typedef value_type (*pg2)(unsigned, value_type);
#if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
   pg2 funcp2 = boost::math::legendre_q<value_type>;
#else
   pg2 funcp2 = boost::math::legendre_q;
#endif

   //
   // test legendre_q against data:
   //
   result = boost::math::tools::test(
      data,
      bind_func_int1(funcp2, 0, 1),
      extract_result(3));
   handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::legendre_q", test_name);
#ifdef TEST_OTHER
   if(::boost::is_floating_point<value_type>::value){
      funcp = other::legendre_q;
   result = boost::math::tools::test(
      data,
      bind_func_int1(funcp2, 0, 1),
      extract_result(3));
      print_test_result(result, data[result.worst()], result.worst(), type_name, "other::legendre_q");
   }
#endif


   std::cout << std::endl;
}