Esempio n. 1
0
TEST(allocate_large_chunk, then_chunk_block_must_be_created)
{    
    int chunk_size_requested = size_alc;
    int chunk_size           = AlignDefault(chunk_size_requested);

	void*           chunkMem = mem_alc;
	MemoryChunk     chunk    = (MemoryChunk)((char*)chunkMem - MEM_CHUNK_SIZE); 

	TEST_ASSERT_NOT_NULL(chunkMem);
    TEST_ASSERT_NOT_NULL(chunk);

	TEST_ASSERT_EQUAL(chunk->memsetorchunk, mc_alc);
	TEST_ASSERT_EQUAL_INT32(chunk->size, chunk_size);
	TEST_ASSERT_EQUAL_INT32(chunk->sizeRequested, chunk_size_requested);
}
Esempio n. 2
0
TEST(shell, hook)
{
	char test_chars[] = {
		'a', '\n', 0
	};
	char *p;

	// OK hook
	s_error = 1;
	p = test_chars;
	s_handle = shell_create(s_pool, POOL_SIZE,
			stub_putc, stub_getc, stub_exec_ok, stub_post_hook);
	TEST_ASSERT_NOT_NULL( s_handle );
	pthread_create(&s_thread, NULL, thread_shell, NULL);
	while (*p) {
		while (s_txc);
		s_txc = *p++;
	}

	pthread_mutex_lock(&s_mutex);
	pthread_cond_wait(&s_cv, &s_mutex);
	pthread_mutex_unlock(&s_mutex);
	TEST_ASSERT_EQUAL_INT32( 0, s_error );
	TEST_ASSERT_UNLESS( shell_destroy(s_handle) );
	s_txc = '\n';
	pthread_join(s_thread, NULL);


	// NG hook
	s_error = 0;
	p = test_chars;
	s_handle = shell_create(s_pool, POOL_SIZE,
			stub_putc, stub_getc, stub_exec_ng, stub_post_hook);
	TEST_ASSERT_NOT_NULL( s_handle );
	pthread_create(&s_thread, NULL, thread_shell, NULL);
	while (*p) {
		while (s_txc);
		s_txc = *p++;
	}
	pthread_mutex_lock(&s_mutex);
	pthread_cond_wait(&s_cv, &s_mutex);
	pthread_mutex_unlock(&s_mutex);
	TEST_ASSERT_EQUAL_INT32( -1, s_error );
	TEST_ASSERT_UNLESS( shell_destroy(s_handle) );
	s_txc = '\n';
	pthread_join(s_thread, NULL);
}
Esempio n. 3
0
void test_mcu_callf(void)
{
  uint32_t address   = 0x556677;
  uint8_t   length   = 4;
  
  SET_PC(0x12BBCC);
  
  mcu_callf( address,  length);    //12BBCC + 4 = 12BBDO
  TEST_ASSERT_EQUAL_INT8(0xD0, MEM_READ_BYTE(inputSP) );   // test is pcl store in the address
  TEST_ASSERT_EQUAL_INT8(0xBB, MEM_READ_BYTE(sp_minus1) );  // test is pch store in the address ( sp decrement)
  TEST_ASSERT_EQUAL_INT8(0x12, MEM_READ_BYTE(sp_minus2) );  // test is pce store in the address ( sp decrement)
  TEST_ASSERT_EQUAL_INT32( address , *pcToLoad );  
  TEST_ASSERT_EQUAL_INT8(inputSP -3, SP ); // test is sp decreament 3 time
}
void
test_IfTable_get_ifOperStatus(void) {
  netsnmp_variable_list data = {0};
  void *lctx = NULL;
  void *dctx1 = NULL;
  void *dctx2 = NULL;
  void *dctx3 = NULL;
  size_t ret_len;

  int32_t *ret_val;

  data.type = ASN_INTEGER;

  ifTable_get_first_data_point(&lctx, &dctx1, &data, NULL);
  ifTable_get_next_data_point(&lctx, &dctx2, &data, NULL);
  ifTable_data_free(dctx2, NULL);
  ifTable_get_next_data_point(&lctx, &dctx3, &data, NULL);
  TEST_ASSERT_NULL(dctx3);
  ifTable_loop_free(lctx, NULL);
  ret_val = get_ifOperStatus(dctx1, &ret_len);
  TEST_ASSERT_NOT_NULL(ret_val);
  TEST_ASSERT_EQUAL_INT32(VALUE_ifOperStatus_1, *ret_val);
  TEST_ASSERT_EQUAL_UINT64(sizeof(*ret_val), ret_len);
  ifTable_data_free(dctx1, NULL);
  ifTable_get_first_data_point(&lctx, &dctx1, &data, NULL);
  ifTable_data_free(dctx1, NULL);
  ifTable_get_next_data_point(&lctx, &dctx2, &data, NULL);
  ifTable_get_next_data_point(&lctx, &dctx3, &data, NULL);
  TEST_ASSERT_NULL(dctx3);
  ifTable_loop_free(lctx, NULL);
  ret_val = get_ifOperStatus(dctx2, &ret_len);
  TEST_ASSERT_NOT_NULL(ret_val);
  TEST_ASSERT_EQUAL_INT32(VALUE_ifOperStatus_2, *ret_val);
  TEST_ASSERT_EQUAL_UINT64(sizeof(*ret_val), ret_len);
  ifTable_data_free(dctx2, NULL);
}
//#define SET_PC(extend)       setBigEndianExt(&PCE, extend)
void test_setBigEndianExt_given_PC(void){
  
  SET_PC(0xABCCD5);
  
  TEST_ASSERT_EQUAL_INT32(0xABCCD5, PC);
}
void test_rcc_AHB1RSTR(void){
  
  rcc->AHB1RSTR = 0x00000001;
  TEST_ASSERT_EQUAL_INT32(0x00000001,rcc->AHB1RSTR);
  
}
_STATIC_ void Test_i32_vect_all_values_equal_to(Vector_i32_t *i32_vect, int32_t compare_value){
	uint8_t i;
	for(i=1; i<=3;i++){
		TEST_ASSERT_EQUAL_INT32(compare_value, Vect_i32_read(i32_vect, i));
	}
}