static int __init ll_init(void)
{
    printk(KERN_ALERT "Hello, linked_lists\n");
    test_stack();
    print_processes_backwards();
    return 0;
}
Example #2
0
int main(int argc, char * argv[]) {
    test_graph();
    test_stack();
    test_chaitin();
    test_chaitin_spill();
    return EXIT_SUCCESS;
}
Example #3
0
static int __init stack_init(void)
{
    printk("init stack module\n");

    test_stack(4);
    
    return 0;
}
Example #4
0
void run_tests() {
	test_entry_expansion();
	test_table_expansion();
	test_automaton_eval();
	test_list();
	test_bs_build();
	test_stack();
	test_queue();
}
Example #5
0
int main(int argc, char* argv[])
{
    test_list();

    test_q();

    test_stack();

    return 0;
}
Example #6
0
int main(int argc, char **argv) {
  struct node *stack = NULL;
  if(argc < 2) {
    printf("call with more args\n");
    exit(0);
  }

  test_stack(argc-1, argv+1);
  test_auxappend(argc-1, argv+1);
}
Example #7
0
int main() {
	/* TESTS FOR STACK.C */
	printf("Testing stack.c functions...\n");
	printf("	stack_new\n");
	printf("	push\n");
	printf("	pop\n");
	printf("	peek\n");
	printf("	reverse\n");
	assert(test_stack());
	printf("All stack.c tests passed!\n");	
	printf("(* Note: all functions tested together, not individually *)\n\n");
}
Example #8
0
int main(int argc, char** argv)
{
    std::cout << "data_structures!" << std::endl;

	test_stack();
	test_array();

	std::cout << "Press Enter to continue...";
	std::cin.get();
    
	return 0;
}
Example #9
0
static void test_stack(unsigned int level)
{
    int     arr[1024];
    int     i;
    
    if (level <= 0)
	return;
    
    for (i = 0; i < 1024; i++)
	arr[i] = i * level;

    test_stack(level - 1);
}
Example #10
0
int main(int argc, char *argv[])
{
	test_list();
	test_dlist();
	test_stack();
	test_evaluate();
	
	puts("##########################################");	
	puts("all tests have been completed!!");
	puts("##########################################");

	return 0;
}
bool test_all()
{
	printf("Test Stack: %s\n",  test_stack()?"PASS":"******");
	printf("Test Queue: %s\n",  test_queue()?"PASS":"******");
	printf("Test List:  %s\n",  test_list()?"PASS":"******");
	printf("Test MinHeap: %s\n",test_minheap()?"PASS":"******");
	printf("Test MaxHeap: %s\n",test_maxheap()?"PASS":"******");
	printf("Test RedBlack: %s\n", /*test_redblack()*/false?"PASS":"******");
	printf("Test BST: %s\n", test_bst()?"PASS":"******");
	printf("Test HashTable: %s\n",test_hashtable()?"PASS":"******");
	printf("Test Tuple: %s\n",test_tuple()?"PASS":"******");
	if(DEBUG)functional_tests();
	return 1;
}
Example #12
0
int main()
{
    char value[10] = "test\n";
    int status = AXIS2_SUCCESS;
    axutil_env_t *env = NULL;
    env = create_environment();
    status = test_stack(env,value);
    if(status != AXIS2_SUCCESS)
    {
        printf("The test failed");
    }
    axutil_env_free(env);
    return 0;
}
Example #13
0
File: test.c Project: Nukem9/Dune
int main(int argc, char *argv[])
{
	printf("==== start\n");

	if (sthread_init())
		err(1, "sthread_init()");

	printf("==== Basic sthread\n");
	test_sthread();
	test_sthread();

	printf("==== Globals\n");
	_global = 2;
	test_global();
	if (_global != 2)
		errx(1, "global in master %d\n", _global);
	test_global();

	printf("==== Stack\n");
	test_stack();
	test_stack();

	printf("==== smalloc\n");
	test_smalloc();

	printf("==== fd\n");
	test_fd();

	printf("==== syscall\n");
	test_syscall();

	printf("==== parallel\n");
	test_parallel();

	printf("==== end\n");
	exit(0);
}
Example #14
0
int main()
{
  dcTest_initPlatform();

  printf("Allocating ...\n");
  printf("... W^X memory: ");
  test_wx();
  printf("... heap memory: ");
  test_heap();
  printf("... stack memory: ");
  test_stack();

  dcTest_deInitPlatform();

  return 0;
}
int main(int argc, const char *argv[]) {
  program_name = argv[0];

  (void) argc;

  test_card();
  test_cursor();
  test_deck();
  test_gui();
  test_frame();
  test_game();
  test_keyboard();
  test_stack();
  test_test_helper();

  return(0);
}
Example #16
0
int main()
{
  dcTest_initPlatform();

  signal(SIGSEGV, segv_handler);

  printf("Allocating ...\n");
  printf("... W^X memory: ");
  test_wx();
  printf("... heap memory: ");
  test_heap();
  printf("... stack memory: ");
  test_stack();

  dcTest_deInitPlatform();

  return 0;
}
Example #17
0
int main()
{
    print_testname("Doubly Linked List"); 
    test_doublylinkedlist(); 

    print_testname("BST"); 
    test_binarysearchtree(); 

    print_testname("Undirected Graph"); 
    test_undirectedgraph(); 

    print_testname("Stack"); 
    test_stack(); 

    print_testname("Queue"); 
    test_queue(); 

    return 0; 
}
Example #18
0
int main()
#endif
{
	tnet_startup();

#if RUN_TEST_LOOP
	for(;;)
#endif
	{
		/* Print copyright information */
		printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n");

		
	
#if RUN_TEST_ALL  || RUN_TEST_MESSAGES
		test_messages();
#endif

#if RUN_TEST_ALL  || RUN_TEST_URI
		test_uri();
#endif

#if RUN_TEST_ALL ||RUN_TEST_TRANSAC
		test_transac();
#endif

#if RUN_TEST_ALL || RUN_TEST_STACK
		test_stack();
#endif

#if RUN_TEST_ALL || RUN_TEST_IMS_AKA
		test_imsaka();
#endif
	}

	tnet_cleanup();

	return 0;
}
Example #19
0
void stack_test( int loop )
{
	// Create the stack
	stack<int> test_stack( 5 );

	for (int i = 0; i < loop; ++i)
	{
		// int add = rand() % loop;
		// std::cout << i << " -> ";
		test_stack.push( i );
	}
	// std::cout << '\n';
	// std::cout << '\n';

	// int * all = test_stack.all();
	// for ( int i = test_stack.size() - 1; i >= 0 ; --i )
	// {
	// 	std::cout << all[ i ] << " -> ";
	// }
	// std::cout << '\n';
	// delete [] all;

	// for ( int i = 0; i < loop / 2; ++i )
	// {
	// 	// std::cout << "pop: " << * test_stack.peek() << '\n';
	// 	test_stack.pop();
	// }

	// all = test_stack.all();
	// for ( int i = 0; i < test_stack.size(); ++i )
	// {
	// 	std::cout << all[ i ] << " -> ";
	// }
	// std::cout << '\n';
	// delete [] all;
}
Example #20
0
int main()
{
    test_stack();
    return 0;
}
Example #21
0
File: 3-2.c Project: Nan619/ltp-ddt
int main(int argc, char *argv[])
{
	int ret = 0;
	int do_stack_tests;
	int do_sched_tests;

	/* Initialize output routine */
	output_init();

	/* Test abilities */
	do_sched_tests = (sysconf(_SC_THREAD_PRIORITY_SCHEDULING) > 0 ? 1 : 0);
	do_stack_tests = (test_stack(NULL, 0) == 0 ? 1 : 0);
#if VERBOSE > 0
	output
	    ("Test starting\n Stack tests %s be executed.\n Sched tests %s be executed.\n",
	     do_stack_tests ? "will" : "won't",
	     do_sched_tests ? "will" : "won't");
#endif

	/* Initialize thread attribute objects */
	scenar_init();

	for (sc = 0; sc < NSCENAR; sc++) {
#if VERBOSE > 0
		output("-----\n");
		output("Starting test with scenario (%i): %s\n", sc,
		       scenarii[sc].descr);
#endif

		if (do_stack_tests) {
			/* stack grow test */
			/* We need the thread attribute to specify a minimal stack */
			if ((scenarii[sc].altstack == 0)
			    && (scenarii[sc].altsize == 1)) {
#if VERBOSE > 2
				output("Processing stack grow test\n");
#endif

				ret =
				    test_stack(&scenarii[sc].ta,
					       2 *
					       sysconf(_SC_THREAD_STACK_MIN));

				if (ret == 0) {
					if (scenarii[sc].guard == 2) {
						FAILED
						    ("Changing the stacksize after the thread was created changed the running thread stack size");
					}
#if VERBOSE > 2
					else
						output
						    ("We were able to overflow the stack, but the guard area is unknow or null\n");
#endif

				}

				if ((ret != 2) && (scenarii[sc].result == 1)) {
					UNRESOLVED(-1,
						   "An error was expected but the thread creation succeeded");
				}
#if VERBOSE > 2
				if ((ret == 1)) {
					output("Stack grow test passed\n");
				}

				if ((ret == 2) && (scenarii[sc].result == 2)) {
					output
					    ("Something went wrong -- we don't care in this case\n");
				}
#endif

				if ((ret == 2) && (scenarii[sc].result == 0)) {
					UNRESOLVED(-1,
						   "An unexpected error occured\n");
				}

				/* Ok, set back the thread attribute object to a correct value */
				ret =
				    pthread_attr_setstacksize(&scenarii[sc].ta,
							      sysconf
							      (_SC_THREAD_STACK_MIN));
				if (ret != 0) {
					UNRESOLVED(ret,
						   "Failed to set stacksize back");
				}
			}

			/* stack decrease test */
			if ((scenarii[sc].altstack == 0)
			    && (scenarii[sc].altsize == 0)) {
#if VERBOSE > 2
				output("Processing stack decrease test\n");
#endif

				ret =
				    test_stack(&scenarii[sc].ta,
					       sysconf(_SC_THREAD_STACK_MIN));

				if (ret == 1) {
					FAILED
					    ("Decreasing the stack size after thread is created had an influence on the thread");
				}

				if ((ret == 0) && (scenarii[sc].result == 1)) {
					UNRESOLVED(-1,
						   "An error was expected but the thread creation succeeded");
				}

				if ((ret == 2) && (scenarii[sc].result == 0)) {
					UNRESOLVED(-1,
						   "An unexpected error occured\n");
				}
#if VERBOSE > 2
				if (ret == 0)
					output("Stack decrease test passed.\n");
				else
					output
					    ("Something failed but we don't care here.\n");
#endif
			}

		}
		/* if do_stack_tests */
		if (do_sched_tests) {
			/* Sched policy/param change test */
			if (scenarii[sc].explicitsched != 0) {	/* We need a specified policy */
				pthread_t child;
				int policy_ori, newpol_max;
				struct sched_param param_ori, tmp;

				testdata_t td;

#if VERBOSE > 2
				output
				    ("Processing sched policy/param change test\n");
#endif

				/* Backup the scenario object */
				ret =
				    pthread_attr_getschedpolicy(&
								(scenarii
								 [sc].ta),
								&policy_ori);
				if (ret != 0) {
					UNRESOLVED(ret,
						   "Unable to read sched policy from thread attribute");
				}
				ret =
				    pthread_attr_getschedparam(&
							       (scenarii
								[sc].ta),
							       &param_ori);
				if (ret != 0) {
					UNRESOLVED(ret,
						   "Unable to read sched param from thread attribute");
				}

				/* Initialize the barrier */
				ret = pthread_barrier_init(&(td.bar), NULL, 2);
				if (ret != 0) {
					UNRESOLVED(ret,
						   "Unable to initialize the barrier");
				}

				/* Create a new thread with this scenario attribute */
				ret =
				    pthread_create(&child, &(scenarii[sc].ta),
						   schedtest, &td);
				if (ret != 0) {
					if (scenarii[sc].result == 0) {
						UNRESOLVED(ret,
							   "Failed to create a thread");
					}
#if VERBOSE > 2
					if (scenarii[sc].result == 2) {
						output
						    ("The thread creation failed -- we don't care\n");
					}
					if (scenarii[sc].result == 1) {
						output
						    ("The thread creation failed as expected\n");
					}
#endif
				} else {	/* Thread created */

					if (scenarii[sc].result == 1) {
						UNRESOLVED(-1,
							   "The thread was created where an error was expected");
					}
#if VERBOSE > 2
					if (scenarii[sc].result == 2)
						output("Thread is created\n");
#endif

					/* sync 1 */
					ret = pthread_barrier_wait(&(td.bar));
					if ((ret != 0)
					    && (ret !=
						PTHREAD_BARRIER_SERIAL_THREAD))
					{
						UNRESOLVED(ret,
							   "Failed to synchronize on the barrier");
					}

					/* Check the new thread reports the attributes */
					if (td.policy != policy_ori) {
						FAILED
						    ("The new thread does not report the scheluling policy that was specified");
					}

					if (td.param.sched_priority !=
					    param_ori.sched_priority) {
						FAILED
						    ("The new thread does not report the scheduling priority that was specified at creation");
					}

					/* Change the thread attribute object policy & param */
					if (policy_ori == SCHED_RR) {
						ret =
						    pthread_attr_setschedpolicy
						    (&(scenarii[sc].ta),
						     SCHED_FIFO);
						newpol_max =
						    sched_get_priority_max
						    (SCHED_FIFO);
					} else {
						ret =
						    pthread_attr_setschedpolicy
						    (&(scenarii[sc].ta),
						     SCHED_RR);
						newpol_max =
						    sched_get_priority_max
						    (SCHED_RR);
					}
					if (ret != 0) {
						UNRESOLVED(ret,
							   "Failed to change the attribute object");
					}

					if (newpol_max ==
					    param_ori.sched_priority)
						newpol_max--;

					tmp.sched_priority = newpol_max;

					ret =
					    pthread_attr_setschedparam(&
								       (scenarii
									[sc].ta),
								       &tmp);
					if (ret != 0) {
						UNRESOLVED(ret,
							   "Failed to set the attribute sched param");
					}

					/* sync 2 */
					ret = pthread_barrier_wait(&(td.bar));
					if ((ret != 0)
					    && (ret !=
						PTHREAD_BARRIER_SERIAL_THREAD))
					{
						UNRESOLVED(ret,
							   "Failed to synchronize on the barrier");
					}

					/* sync 3 */
					ret = pthread_barrier_wait(&(td.bar));
					if ((ret != 0)
					    && (ret !=
						PTHREAD_BARRIER_SERIAL_THREAD))
					{
						UNRESOLVED(ret,
							   "Failed to synchronize on the barrier");
					}

					/* Check if the thread saw the change (should not) */
					if (td.policy != policy_ori) {
						FAILED
						    ("The new thread does not report the scheluling policy that was specified");
					}

					if (td.param.sched_priority !=
					    param_ori.sched_priority) {
						FAILED
						    ("The new thread does not report the scheduling priority that was specified at creation");
					}

					/* Check what we can see for the child thread from here */
					ret =
					    pthread_getschedparam(child,
								  &(td.policy),
								  &(td.param));
					if (ret != 0) {
						UNRESOLVED(ret,
							   "Failed to read child thread policy / param");
					}

					if (td.policy != policy_ori) {
						FAILED
						    ("The child thread does not report the scheduling policy that was specified at creation");
					}

					if (td.param.sched_priority !=
					    param_ori.sched_priority) {
						FAILED
						    ("The child thread does not report the scheduling priority that was specified at creation");
					}

					/* Restore the thread attribute */
					ret =
					    pthread_attr_setschedpolicy(&
									(scenarii
									 [sc].ta),
									policy_ori);
					if (ret != 0) {
						UNRESOLVED(ret,
							   "Unable to read sched policy from thread attribute");
					}
					ret =
					    pthread_attr_setschedparam(&
								       (scenarii
									[sc].ta),
								       &param_ori);
					if (ret != 0) {
						UNRESOLVED(ret,
							   "Unable to read sched param from thread attribute");
					}

					/* sync 4 */
					ret = pthread_barrier_wait(&(td.bar));
					if ((ret != 0)
					    && (ret !=
						PTHREAD_BARRIER_SERIAL_THREAD))
					{
						UNRESOLVED(ret,
							   "Failed to synchronize on the barrier");
					}

					/* sync 5 */
					ret = pthread_barrier_wait(&(td.bar));
					if ((ret != 0)
					    && (ret !=
						PTHREAD_BARRIER_SERIAL_THREAD))
					{
						UNRESOLVED(ret,
							   "Failed to synchronize on the barrier");
					}

					/* check if the thread attribute reports a change (should not) */
					ret =
					    pthread_attr_getschedpolicy(&
									(scenarii
									 [sc].ta),
									&
									(td.policy));
					if (ret != 0) {
						UNRESOLVED(ret,
							   "Unable to read sched policy from thread attribute");
					}
					ret =
					    pthread_attr_getschedparam(&
								       (scenarii
									[sc].ta),
								       &
								       (td.param));
					if (ret != 0) {
						UNRESOLVED(ret,
							   "Unable to read sched param from thread attribute");
					}

					if (td.policy != policy_ori) {
						FAILED
						    ("The child thread does not report the scheduling policy that was specified at creation");
					}

					if (td.param.sched_priority !=
					    param_ori.sched_priority) {
						FAILED
						    ("The child thread does not report the scheduling priority that was specified at creation");
					}

					/* Wait for the sem and join eventually the thread */
					do {
						ret =
						    sem_wait(&scenarii[sc].sem);
					}
					while ((ret == -1) && (errno == EINTR));
					if (ret == -1) {
						UNRESOLVED(errno,
							   "Failed to wait for the semaphore");
					}

					if (scenarii[sc].detached == 0) {
						ret = pthread_join(child, NULL);
						if (ret != 0) {
							UNRESOLVED(ret,
								   "Unable to join a thread");
						}
					}
#if VERBOSE > 2
					output
					    ("Sched policy/param change test passed\n");
#endif
				}	/* thread created */
			}

			/* We could also test if the inheritsched does not influence the new thread */

		}		/* if do_sched_tests */
	}

	scenar_fini();
#if VERBOSE > 0
	output("-----\n");
	output("All test data destroyed\n");
	output("Test PASSED\n");
#endif

	PASSED;
}
Example #22
0
int
main (void)
{
  atexit (check_called);

  char st1[32768];
  stack_t stack_before, stack_after;

  sigaltstack (NULL, &stack_before);

  puts ("making contexts");
  if (getcontext (&ctx[1]) != 0)
    {
      if (errno == ENOSYS)
	{
	  back_in_main = 1;
	  exit (0);
	}

      printf ("%s: getcontext: %m\n", __FUNCTION__);
      exit (1);
    }

  test_stack (1, 2, 3, 4);

  /* Play some tricks with this context.  */
  if (++global == 1)
    if (setcontext (&ctx[1]) != 0)
      {
	printf ("%s: setcontext: %m\n", __FUNCTION__);
	exit (1);
      }
  if (global != 2)
    {
      printf ("%s: 'global' not incremented twice\n", __FUNCTION__);
      exit (1);
    }

  ctx[1].uc_stack.ss_sp = st1;
  ctx[1].uc_stack.ss_size = sizeof st1;
  ctx[1].uc_link = &ctx[0];
  {
    ucontext_t tempctx = ctx[1];
    makecontext (&ctx[1], (void (*) (void)) f1, 4, 1, 2, 3, -4);

    /* Without this check, a stub makecontext can make us spin forever.  */
    if (memcmp (&tempctx, &ctx[1], sizeof ctx[1]) == 0)
      {
	puts ("makecontext was a no-op, presuming not implemented");
	return 0;
      }
  }

  if (getcontext (&ctx[2]) != 0)
    {
      printf ("%s: second getcontext: %m\n", __FUNCTION__);
      exit (1);
    }
  ctx[2].uc_stack.ss_sp = st2;
  ctx[2].uc_stack.ss_size = sizeof st2;
  ctx[2].uc_link = &ctx[1];
  makecontext (&ctx[2], f2, 0);

  puts ("swapping contexts");
  if (swapcontext (&ctx[0], &ctx[2]) != 0)
    {
      printf ("%s: swapcontext: %m\n", __FUNCTION__);
      exit (1);
    }
  puts ("back at main program");
  back_in_main = 1;

  sigaltstack (NULL, &stack_after);

  if (was_in_f1 == 0)
    {
      puts ("didn't reach f1");
      exit (1);
    }
  if (was_in_f2 == 0)
    {
      puts ("didn't reach f2");
      exit (1);
    }

  /* Check sigaltstack state is not clobbered as in BZ #16629.  */
  if (stack_before.ss_sp != stack_after.ss_sp)
    {
      printf ("stack ss_sp mismatch: %p %p\n",
	      stack_before.ss_sp, stack_after.ss_sp);
      exit (1);
    }

  if (stack_before.ss_size != stack_after.ss_size)
    {
      printf ("stack ss_size mismatch: %zd %zd\n",
	      stack_before.ss_size, stack_after.ss_size);
      exit (1);
    }

  puts ("test succeeded");
  return 0;
}
int
main (void)
{
  char st1[32768];

  puts ("making contexts");
  if (getcontext (&ctx[1]) != 0)
    {
      if (errno == ENOSYS)
	exit (0);

      printf ("%s: getcontext: %m\n", __FUNCTION__);
      exit (1);
    }

  test_stack (1, 2, 3, 4);

  /* Play some tricks with this context.  */
  if (++global == 1)
    if (setcontext (&ctx[1]) != 0)
      {
	printf ("%s: setcontext: %m\n", __FUNCTION__);
	exit (1);
      }
  if (global != 2)
    {
      printf ("%s: 'global' not incremented twice\n", __FUNCTION__);
      exit (1);
    }

  ctx[1].uc_stack.ss_sp = st1;
  ctx[1].uc_stack.ss_size = sizeof st1;
  ctx[1].uc_link = &ctx[0];
  {
    ucontext_t tempctx = ctx[1];
    makecontext (&ctx[1], (void (*) (void)) f1, 4, 1, 2, 3, -4);

    /* Without this check, a stub makecontext can make us spin forever.  */
    if (memcmp (&tempctx, &ctx[1], sizeof ctx[1]) == 0)
      {
	puts ("makecontext was a no-op, presuming not implemented");
	return 0;
      }
  }

  if (getcontext (&ctx[2]) != 0)
    {
      printf ("%s: second getcontext: %m\n", __FUNCTION__);
      exit (1);
    }
  ctx[2].uc_stack.ss_sp = st2;
  ctx[2].uc_stack.ss_size = sizeof st2;
  ctx[2].uc_link = &ctx[1];
  makecontext (&ctx[2], f2, 0);

  puts ("swapping contexts");
  if (swapcontext (&ctx[0], &ctx[2]) != 0)
    {
      printf ("%s: swapcontext: %m\n", __FUNCTION__);
      exit (1);
    }
  puts ("back at main program");

  if (was_in_f1 == 0)
    {
      puts ("didn't reach f1");
      exit (1);
    }
  if (was_in_f2 == 0)
    {
      puts ("didn't reach f2");
      exit (1);
    }

  puts ("test succeeded");
  return 0;
}