void create_readers_slow(){ readers[0]=reader_initialize("Reader 1",4,dim); readers[1]=reader_initialize("Reader 2",5,dim); readers[2]=reader_initialize("Reader 3",7,dim); readers[3]=reader_initialize("Reader 4",10,dim); readers[4]=reader_initialize("Reader 5",1,dim); }
void create_readers(){ readers[0]=reader_initialize("Reader 1",1,dim); readers[1]=reader_initialize("Reader 2",2,dim); readers[2]=reader_initialize("Reader 3",4,dim); readers[3]=reader_initialize("Reader 4",3,dim); readers[4]=reader_initialize("Reader 5",5,dim); }
void test_reader_list_broadcast(){ reader_list_initialize(); reader_t* reader_ritardoUnitario_bufferGenerico=reader_initialize("Reader 1",1,10); reader_t* reader_ritardo5_bufferGenerico=reader_initialize("Reader 2", 5,2); add_twoReaders(reader_ritardoUnitario_bufferGenerico,reader_ritardo5_bufferGenerico); reader_list_broadcast(messaggio); ASSERT_BUFFER_CONTAINS_ONLY(reader_ritardoUnitario_bufferGenerico->buffer->read_buffer, messaggio); ASSERT_BUFFER_CONTAINS_ONLY(reader_ritardo5_bufferGenerico->buffer->read_buffer, messaggio); clean_buffer_reader(reader_ritardoUnitario_bufferGenerico, reader_ritardo5_bufferGenerico); remove_twoReaders(reader_ritardoUnitario_bufferGenerico,reader_ritardo5_bufferGenerico); reader_list_destroy(); }
void test_reader_list_kill(){ reader_list_initialize(); reader_t* reader_ritardoUnitario_bufferGenerico=reader_initialize("Reader 1",1,10); reader_t* reader_ritardo5_bufferUnitario=reader_initialize("Reader 2",5,1); add_twoReaders(reader_ritardoUnitario_bufferGenerico,reader_ritardo5_bufferUnitario); reader_list_kill(); ASSERT_BUFFER_CONTAINS_ONLY(reader_ritardoUnitario_bufferGenerico->buffer->read_buffer, (msg_t*)&POISON_PILL_MSG); ASSERT_BUFFER_CONTAINS_ONLY(reader_ritardo5_bufferUnitario->buffer->read_buffer, (msg_t*)&POISON_PILL_MSG); clean_buffer_reader(reader_ritardoUnitario_bufferGenerico, reader_ritardo5_bufferUnitario); remove_twoReaders(reader_ritardoUnitario_bufferGenerico,reader_ritardo5_bufferUnitario); reader_list_destroy(); }
int reader_before1() { reader_list_initialize(); reader_ritardo5_bufferUnitario=reader_initialize("Reader 1",5,1); reader_ritardoUnitario_bufferGenerico=reader_initialize("Reader 2",1,8); int i; for (i=0; i<8; i++) { messages[i]=msg_init((void*)(i*10)); } reader_list_addReader((void*)reader_ritardo5_bufferUnitario); reader_list_addReader((void*)reader_ritardoUnitario_bufferGenerico); return 0; }
void test_reader_list_addTwoReaders(){ reader_list_initialize(); CU_ASSERT_EQUAL(reader_list_size(),0); reader_t* reader_ritardoUnitario_bufferGenerico=reader_initialize("Reader 1",1,10); reader_t* reader_ritardo5_bufferUnitario=reader_initialize("Reader 2",5,1); add_twoReaders(reader_ritardoUnitario_bufferGenerico,reader_ritardo5_bufferUnitario); CU_ASSERT_PTR_NOT_NULL(reader_list->head); CU_ASSERT_PTR_NOT_NULL(reader_list->tail); CU_ASSERT_PTR_NOT_EQUAL(reader_list->head, reader_list->tail); CU_ASSERT_PTR_EQUAL(reader_list->head->next, reader_list->tail); CU_ASSERT_EQUAL(reader_list_size(),2); remove_twoReaders(reader_ritardoUnitario_bufferGenerico,reader_ritardo5_bufferUnitario); reader_list_destroy(); }
void test_reader_list_isNotEmpty(){ reader_list_initialize(); reader_t* reader_ritardo5_bufferUnitario=reader_initialize("Reader 2",5,1); reader_list_addReader((void*)reader_ritardo5_bufferUnitario); CU_ASSERT_FALSE(reader_list_isEmpty()); reader_destroy(reader_ritardo5_bufferUnitario); reader_list_destroy(); }
void test_reader_list_addOneReader(){ reader_list_initialize(); reader_t* reader_ritardoUnitario_bufferGenerico=reader_initialize("Reader 1",1,10); CU_ASSERT_EQUAL(reader_list_size(),0); reader_list_addReader((void*)reader_ritardoUnitario_bufferGenerico); CU_ASSERT_PTR_NOT_NULL(reader_list->head); CU_ASSERT_PTR_NOT_NULL(reader_list->tail); CU_ASSERT_PTR_EQUAL(reader_list->head, reader_list->tail); CU_ASSERT_EQUAL(reader_list_size(),1); reader_destroy(reader_ritardoUnitario_bufferGenerico); reader_list_destroy(); }