예제 #1
0
파일: test.c 프로젝트: wtracy/dog
void test_wrap_multi() {
  buffer_init(2);
  g_assert(buffer_push(4095));

  /*fprintf(stderr, "is_index_wrapped(0) = %d\n", is_index_wrapped(0));*/
  g_assert(!is_index_wrapped(0));
  g_assert(!is_index_wrapped(1));

  g_assert(buffer_pop(2048, 0));
  g_assert(buffer_pop(4095, 1));

  g_assert(!is_index_wrapped(0));
  g_assert(!is_index_wrapped(1));

  g_assert(buffer_push(1));
  g_assert(head_at_start_position());
  g_assert(buffer_push(1024));
  g_assert(buffer_pop(1, 1));
  g_assert(buffer_pop(100, 1));

  g_assert(is_index_wrapped(0));
  g_assert(!is_index_wrapped(1));
  
  g_assert(buffer_pop(2048, 0));
  g_assert(buffer_pop(120, 0));
 
  g_assert(!is_index_wrapped(0));
  g_assert(!is_index_wrapped(1));

  buffer_free();
}
예제 #2
0
/*
 * Funcion que acumula en data los contenidos de todas las lineas del stream de
 * entrada usando el buffer de acumulacion dado.
 */
int accumulate_lines(struct data_t* data, FILE* stream, struct buffer_t* buffer) {
  int raw_char;
  char actual_char;
  struct line_t* new_line;
  int result;

  LOG_DATA_DEBUG("Accumulating lines");
  for (raw_char = fgetc(stream); !feof(stream) || buffer_pending(buffer); raw_char = fgetc(stream)) {
    actual_char = (char) raw_char;

    /* Check if we have a complete line to push into the data table */
    if ((!feof(stream) && actual_char == '\n') || (feof(stream) && buffer_pending(buffer))) {

      /* If we are not at the end of the stream, we need to push the \n to the buffer */
      if (!feof(stream)) {
        result = buffer_push(buffer, actual_char);
        if (!result) {
          LOG_DATA_DEBUG("Unable to push char into buffer in accumulate_lines");
          LOG_ERROR("Unable to push char into line buffer");
        }
      }

      /* Push the new line to the data table */
      new_line = buffer_reset(buffer);
      if (!new_line) {
        LOG_DATA_DEBUG("Unable to reset buffer in accumulate_lines");
        LOG_ERROR("Unable to obtain full line from buffer");
        return 0;
      }

      result = data_pushline(data, new_line);
      if (!result) {
        LOG_DATA_DEBUG("Unable to push new line in accumulate_lines");
        LOG_ERROR("Unable to push new line in data buffer");
        return 0;
      }
      LOG_DATA_DEBUG("Pushed line to data buffer");
    } else {

      /* Another char was read from the stream, push it to the buffer */
      result = buffer_push(buffer, actual_char);
      if (!result) {
        LOG_DATA_DEBUG("Unable to push char into buffer in accumulate_lines");
        LOG_ERROR("Unable to push char into line buffer");
        return 0;
      }
    }
  }

  return 1;
}
예제 #3
0
파일: lserial.c 프로젝트: zhoukk/routine
static int buffer_push_array(lua_State *L, struct buffer *b, int idx, int depth) {
	int i;
	int array_size = lua_rawlen(L, idx);
	lua_Integer v = array_size;
	uint8_t type = TYPE_TABLE;
	buffer_push(b, (char *)&type, 1);
	buffer_push(b, (char *)&v, sizeof v);
	for (i=1; i<=array_size; i++) {
		lua_rawgeti(L, idx, i);
		lpack_one(L, b, -1, depth);
		lua_pop(L, 1);
	}
	return array_size;
}
예제 #4
0
static void test2() {
    struct Buffer *buffer;
    char input[] = "Testing wrap around behaviour.";
    char output[sizeof(input)];
    int len, i = 0;

    buffer = new_buffer(200, EV_DEFAULT);
    assert(buffer != NULL);

    while (i < 180) {
        len = buffer_push(buffer, input, sizeof(input));
        assert(len == sizeof(input));

        i += len;
    }

    while (len) {
        len = buffer_pop(buffer, output, sizeof(output));
    }

    len = buffer_push(buffer, input, sizeof(input));
    assert(len == sizeof(input));


    len = buffer_peek(buffer, output, sizeof(output));
    assert(len == sizeof(input));

    for (i = 0; i < len; i++)
        assert(input[i] == output[i]);

    len = buffer_pop(buffer, output, sizeof(output));
    assert(len == sizeof(input));

    for (i = 0; i < len; i++)
        assert(input[i] == output[i]);

    len = buffer_push(buffer, input, sizeof(input));
    assert(len == sizeof(input));


    len = buffer_peek(buffer, output, sizeof(output));
    assert(len == sizeof(input));

    for (i = 0; i < len; i++)
        assert(input[i] == output[i]);

    free_buffer(buffer);
}
예제 #5
0
파일: gpiodump.c 프로젝트: 23ars/bbbtools
void *producer(void *ptr)
{
	struct s_VcdFormatValues buffervalues;
	static uint64_t nr_of_captures=0;
	const uint8_t mem_offset=4;
	while (producer_running)
	{
		pthread_mutex_lock(&shared_var_mutex);
		while (buffer_full(&dataCapturedValues))
		{
			pthread_cond_wait(&cond_producer, &shared_var_mutex);
		}
		/*Capture values from */

		dbg("\tWaiting for event...\n");
		prussdrv_pru_wait_event(PRU_EVTOUT_0);
		prussdrv_pru_clear_event(PRU_EVTOUT_0, PRU1_ARM_INTERRUPT);
		buffervalues.values=shared_ram[mem_offset];
		buffervalues.seconds = sample_delay*nr_of_captures++;
		(void) buffer_push(&dataCapturedValues, buffervalues);
	
		pthread_cond_signal(&cond_consumer);/*wake up consumer*/
		pthread_mutex_unlock(&shared_var_mutex);
	}
	pthread_exit(0);
}
예제 #6
0
END_TEST


/**
 * Make sure things are sometimes accepted and sometimes not.
 *
 * Note this test assumes (incorrectly, but practically) that the probability of
 * all zeros or all ones is 0.0. If the test fails, double check that the random
 * numbers generated aren't the cause.
 */
START_TEST (test_50_50)
{
	INIT_CON(); SET_CON_BERNOULLI(0.5);
	
	// Fill the buffer with packets, some of which will be accepted
	for (int i = 0; i < BUFFER_SIZE; i++)
		buffer_push(&b, spinn_packet_pool_palloc(&pool));
	
	for (int i = 0; i < PERIOD * BUFFER_SIZE; i++)
		scheduler_tick_tock(&s);
	
	// Make sure some packets got accepted and others didn't
	ck_assert(!buffer_is_empty(&b));
	ck_assert(!buffer_is_full(&b));
	
	ck_assert(packets_received > 0);
	ck_assert(packets_received < BUFFER_SIZE);
}
예제 #7
0
void test1() {
    struct Buffer *buffer;
    char input[] = "This is a test.";
    char output[sizeof(input)];
    int len, i;

    buffer = new_buffer();

    len = buffer_push(buffer, input, sizeof(input));
    assert(len == sizeof(input));


    len = buffer_peek(buffer, output, sizeof(output));
    assert(len == sizeof(input));

    for (i = 0; i < len; i++)
        assert(input[i] == output[i]);

    len = buffer_peek(buffer, output, sizeof(output));
    assert(len == sizeof(input));

    for (i = 0; i < len; i++)
        assert(input[i] == output[i]);

    len = buffer_pop(buffer, output, sizeof(output));
    assert(len == sizeof(input));

    for (i = 0; i < len; i++)
        assert(input[i] == output[i]);

    len = buffer_pop(buffer, output, sizeof(output));
    assert(len == 0);
    
    free_buffer(buffer);
}
예제 #8
0
END_TEST


/**
 * Make sure everything is accepted if the probability of acceptance is 1.0.
 */
START_TEST (test_active)
{
	INIT_CON(); SET_CON_BERNOULLI(1.0);
	
	// Fill the buffer with packets which will all be accepted
	for (int i = 0; i < BUFFER_SIZE; i++)
		buffer_push(&b, spinn_packet_pool_palloc(&pool));
	
	// Make sure all packets are accepted in the expected timeframe
	for (int i = 0; i < PERIOD * BUFFER_SIZE; i++)
		scheduler_tick_tock(&s);
	ck_assert(buffer_is_empty(&b));
	
	ck_assert_int_eq(packets_received, BUFFER_SIZE);
	
	// Make sure nothing catches fire when the buffer is empty
	for (int i = 0; i < PERIOD * BUFFER_SIZE; i++)
		scheduler_tick_tock(&s);
	
	ck_assert_int_eq(packets_received, BUFFER_SIZE);
}
예제 #9
0
static void test3() {
    struct Buffer *buffer;
    char input[] = "Test buffer resizing.";
    char output[sizeof(input)];
    int len, i;

    buffer = new_buffer(200, EV_DEFAULT);
    assert(buffer != NULL);

    len = buffer_push(buffer, input, sizeof(input));
    assert(len == sizeof(input));

    /* Test resizing to too small of a buffer size */
    len = buffer_resize(buffer, 5);
    assert(len == -1);


    buffer_resize(buffer, 40);
    assert(buffer_room(buffer) == 40 - sizeof(input));

    len = buffer_peek(buffer, output, sizeof(output));
    assert(len == sizeof(input));

    for (i = 0; i < len; i++)
        assert(input[i] == output[i]);

    free_buffer(buffer);
}
예제 #10
0
/*-----------------------------------------------------------------------------*
 *  RPMSG callbacks setup by remoteproc_resource_init()
 *-----------------------------------------------------------------------------*/
static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
                void * priv, unsigned long src)
{
	/* callback data are lost on return and need to be saved */
	if (!buffer_push(data, len)) {
		xil_printf("warning: cannot save data\n");
	}
}
예제 #11
0
파일: test.c 프로젝트: wtracy/dog
void test_space_after_wrapped() {
  buffer_init(1);
  g_assert(buffer_push(100));
  g_assert(buffer_pop(100, 0));
  g_assert_cmpint(0, ==, get_available_to_read(0));
  g_assert(!is_wrapped(get_longest_tail()));
  g_assert(buffer_push(3996));
  g_assert(head_at_start_position());
  g_assert(is_wrapped(get_longest_tail()));
  g_assert(buffer_push(99));
  g_assert(is_wrapped(get_longest_tail()));
  g_assert_cmpint(0, ==, get_space_free());
  g_assert_cmpint(4095, ==, get_space_used());
  g_assert_cmpint(get_space_free(), >=, get_available_to_write());
  g_assert_cmpint(get_space_used(), >=, get_available_to_read(0));
  buffer_free();
}
예제 #12
0
	void send(const T& data) {
		// basically, two options:
		//   - we can provide data
		//   - we have to wait until we provide a value
		// if the buffer is full (always full if synchronous), we have to wait.
		std::cerr << "[send: entered send]\n";
		buffer_lock.lock();
		std::cerr << "[send: got buffer lock]\n";
		if (buffer_has_place()) {
			std::cerr << "[send: buffer has place]\n";
			// we can in fact provide a value
			buffer_push(data);
			std::cerr << "[send: pushed data]\n";
			buffer_lock.unlock();
			std::cerr << "[send: unlocked buffer]\n";
			// it is possible someone was waiting for data to arrive, notify (one of) them.
			needs_value.unlock();
			std::cerr << "[send: unlocked needs_value]\n";
		} else {
			// we have to wait until we provide a value
			buffer_lock.unlock();
			std::cerr << "[send: unlocked buffer]\n";
			provides_value.lock();
			std::cerr << "[send: single lock provides_value]\n";
			provides_value.lock();
			
			std::cerr << "[send: double lock unlocked]\n";
			// unlocked by receiver
			buffer_lock.lock();
			std::cerr << "[send: got buffer lock]\n";
			assert(buffer_has_place() or (buffer_cap == 0));
			// we can in fact provide a value
			buffer_push(data);
			std::cerr << "[send: pushed data]\n";
			buffer_lock.unlock();
			std::cerr << "[send: unlocked buffer]\n";
			// unlock the double lock
			provides_value.unlock();
			std::cerr << "[send: unlocked double lock]\n";
			
			// it is possible someone was waiting for data to arrive, notify (one of) them.
			needs_value.unlock();
			std::cerr << "[send: unlocked needs_value]\n";
		}
	}
예제 #13
0
파일: test.c 프로젝트: wtracy/dog
void test_space_after_fill_buffer() {
  buffer_init(1);
  g_assert(buffer_push(4095));
  g_assert_cmpint(0, ==, get_space_free());
  g_assert_cmpint(4095, ==, get_space_used());
  g_assert_cmpint(get_space_free(), >=, get_available_to_write());
  g_assert_cmpint(get_space_used(), >=, get_available_to_read(0));
  buffer_free();
}
예제 #14
0
END_TEST


/**
 * Ensure with a periodic interval, packets are received at the correct times
 * when the input is empty.
 */
START_TEST (test_periodic_blocked)
{
	INIT_CON();
	SET_CON_PERIODIC(INTERVAL);
	
	// Run the generator for one and a half intervals, during which time nothing
	// should be received and we end up at what would be mid-interval had a packet
	// been received.
	for (int j = 0; j < PERIOD*(INTERVAL + (INTERVAL/2)); j++) {
		scheduler_tick_tock(&s);
		// Nothing should have got through
		ck_assert_int_eq(packets_received, 0);
	}
	
	// If a couple of packets are added to the buffer, the consumer should
	// immediately consume a packet.
	buffer_push(&b, spinn_packet_pool_palloc(&pool));
	buffer_push(&b, spinn_packet_pool_palloc(&pool));
	for (int k = 0; k < PERIOD; k++)
		scheduler_tick_tock(&s);
	ck_assert_int_eq(packets_received, 1);
	ck_assert(!buffer_is_empty(&b));
	
	// The consumer should then consume a further packet exactly one interval
	// later
	for (int j = 0; j < INTERVAL; j++) {
		// The second value should not have got through yet
		ck_assert_int_eq(packets_received, 1);
		
		for (int k = 0; k < PERIOD; k++) {
			scheduler_tick_tock(&s);
		}
	}
	ck_assert_int_eq(packets_received, 2);
	ck_assert(buffer_is_empty(&b));
}
예제 #15
0
파일: ewah_bitmap.c 프로젝트: 0369/git
static size_t add_literal(struct ewah_bitmap *self, eword_t new_data)
{
	eword_t current_num = rlw_get_literal_words(self->rlw);

	if (current_num >= RLW_LARGEST_LITERAL_COUNT) {
		buffer_push_rlw(self, 0);

		rlw_set_literal_words(self->rlw, 1);
		buffer_push(self, new_data);
		return 2;
	}

	rlw_set_literal_words(self->rlw, current_num + 1);

	/* sanity check */
	assert(rlw_get_literal_words(self->rlw) == current_num + 1);

	buffer_push(self, new_data);
	return 1;
}
예제 #16
0
파일: loop.c 프로젝트: kitnic/mod12003
/**
 * Push a byte to the buffer and trigger a transmission. This does clear and set the
 * interrupts, and must not run from the same interrupt level as LOOP_DREINTLVL.
 *
 * This function will spin until the buffer is ready, so do not call it if the
 * USART is not enabled or the DRE interrupt will not run for any reason. It will
 * result in a deadlock in that case.
 *
 * @param byte - the byte to send
 * @param crc - iff true, also push the byte to the CRC peripheral
 */
void buffer_send(uint8_t byte, bool crc)
{
    for (;;) {
        disable_dre();
        if (!buffer_push(byte)) {
            enable_dre();
            break;
        }
    }
    if (crc)
        crc_process_byte(byte);
}
예제 #17
0
파일: lserial.c 프로젝트: zhoukk/routine
static void buffer_push_metapairs(lua_State *L, struct buffer *b, int idx, int depth) {
	uint8_t type = TYPE_TABLE;
	lua_Integer v = 0;
	buffer_push(b, (char *)&type, 1);
	buffer_push(b, (char *)&v, sizeof v);
	lua_pushvalue(L, idx);
	lua_call(L, 1, 3);
	for (;;) {
		lua_pushvalue(L, -2);
		lua_pushvalue(L, -2);
		lua_copy(L, -5, -3);
		lua_call(L, 2, 2);
		if (lua_type(L, -2) == LUA_TNIL) {
			lua_pop(L, 4);
			break;
		}
		lpack_one(L, b, -2, depth);
		lpack_one(L, b, -1, depth);
		lua_pop(L, 1);
	}
	buffer_push_nil(b);
}
예제 #18
0
파일: lbuffer.c 프로젝트: nan1888/lask
/*
** self = buffer:putstr(str1, str2, ..., strN)
*/
static int lbuffer_putstr(lua_State *L)
{
	Buffer *buffer = buffer_lcheck(L, 1);
	int top = lua_gettop(L);
	
	for (int i = 2; i <= top; i++) {
		size_t len;
		const char *str = luaL_checklstring(L, i, &len);
		buffer_push(buffer, str, len);
	}
	
	lua_pushvalue(L, 1);
	return 1;
}
예제 #19
0
void
win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp,
    int flags, theme_item_t theme_item, const char * const from, const char * const message)
{
    GDateTime *time;

    if (tstamp == NULL) {
        time = g_date_time_new_now_local();
    } else {
        time = g_date_time_new_from_timeval_utc(tstamp);
    }

    buffer_push(window->buffer, show_char, time, flags, theme_item, from, message);
    _win_print(window, show_char, time, flags, theme_item, from, message);
}
예제 #20
0
		void hpc_logger::flush_all_buffers_at_exit()
		{
			std::vector<int> threads;
			hpc_log_manager::instance().get_all_keys(threads);

			for (auto& tid : threads)
			{
				__hpc_log_info__* log;
				if (!hpc_log_manager::instance().get(tid, log))
					continue;

				buffer_push(log->buffer, static_cast<int>(log->next_write_ptr - log->buffer));

				hpc_log_manager::instance().remove(tid);
			}
		}
예제 #21
0
void
win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp,
    int flags, theme_item_t theme_item, const char *const from, const char *const message)
{
    if (timestamp == NULL) {
        timestamp = g_date_time_new_now_local();
    } else {
        g_date_time_ref(timestamp);
    }

    buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL);
    _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL);
    // TODO: cross-reference.. this should be replaced by a real event-based system
    inp_nonblocking(TRUE);
    g_date_time_unref(timestamp);
}
예제 #22
0
파일: test.c 프로젝트: wtracy/dog
void test_read_write_one_at_a_time() {
  int i;
  int* pointer;

  buffer_init(1);
  for (i = 0; i < 9000; ++i) {
    g_assert_cmpint(get_available_to_write(), >=, sizeof(int));
    pointer = (int*)get_write_buffer();
    *pointer = i;
    g_assert(buffer_push(sizeof(int)));
    g_assert_cmpint(get_available_to_read(0), >=, sizeof(int));
    pointer = (int*)get_read_buffer(0);
    g_assert_cmpint(*pointer, ==, i);
    g_assert(buffer_pop(sizeof(int), 0));
  }
  buffer_free();
}
예제 #23
0
파일: test.c 프로젝트: wtracy/dog
void test_fill_drain() {
  int i;
  int* pointer;

  buffer_init(1);
  for (i = 0; i < 1023; ++i) {
    pointer = (int*)get_write_buffer();
    *pointer = i;
    g_assert(buffer_push(sizeof(int)));
  }
  for (i = 0; i < 1023; ++i) {
    pointer = (int*)get_read_buffer(0);
    g_assert_cmpint(*pointer, ==, i);
    g_assert(buffer_pop(sizeof(int), 0));
  }
  buffer_free();
}
예제 #24
0
static void test_buffer_coalesce() {
    struct Buffer *buffer;
    char input[] = "Test buffer resizing.";
    char output[sizeof(input)];
    int len;

    buffer = new_buffer(4096, EV_DEFAULT);
    len = buffer_push(buffer, input, sizeof(input));
    assert(len == sizeof(input));

    len = buffer_pop(buffer, output, sizeof(output));
    assert(len == sizeof(output));
    assert(buffer_len(buffer) == 0);
    assert(buffer->head != 0);

    len = buffer_coalesce(buffer, NULL);
}
예제 #25
0
파일: inlinedata.c 프로젝트: new299/wflow
int inline_data_receive(char *data,int length) {

  if(processing_png == true) {
    if(file_end==1) {processing_png=false; return 1;}
    char decoded_buffer[10240]; // should be malloc'd based on length.
    bool failflag;
    int decoded_buffer_size = base64_decode(data,length,decoded_buffer,&failflag);
 
    if(decoded_buffer_size != 0) {
      inlinepng_process_data(decoded_buffer,decoded_buffer_size);
      if(file_end==1) { processing_png=false; return 1; }
    }

    if(failflag == true) {
      file_end =1;
      processing_png=false;
      return 2;
    }
    if(file_end==1) processing_png=false;
    return 1;
  }

  file_end=0;
  buffer_push(data,length);
  int pos = buffer_search(inline_magic);

  if(pos < 0) return 0;

  processing_png=true;

  base64_init();
  initialize_png_reader();
  char decoded_buffer[4096]; // should be malloc'd based on length.
  bool failflag;
  int decoded_buffer_size = base64_decode(buffer+pos+strlen(inline_magic),buffer_size-pos-strlen(inline_magic),decoded_buffer,&failflag);
  if(decoded_buffer_size != 0) {
    inlinepng_process_data(decoded_buffer,decoded_buffer_size);
  }
  buffer_clear();

  if(failflag) {
    processing_png=false;
    return 0;
  }
  return 2;
}
예제 #26
0
파일: uart.c 프로젝트: InnitApps/RocketPack
__interrupt void USCI_A0_ISR(void)
{
  switch(__even_in_range(UCA0IV,0x08))
  {
  case 0:							// Vector 0 - no interrupt
	  break;
  case 2:                           // Vector 2 - RXIFG
	    byte = UCA0RXBUF;
	    RADIORXERROR = buffer_push(byte, &radio_rx_buffer);
	    //radio_send_byte(byte);
	    if (radio_rx_buffer.packets_rxd) LPM0_EXIT;
	  break;
  case 4:    						// Vector 4 - TXIFG
	  break;
  default:
	  break;
  }
}
예제 #27
0
internal void
PopulateAbundantNumberList()
{
    u32 *List = 0;
    
    for(u32 PotentialAbundantNumber = 1;
        PotentialAbundantNumber < AbundantNumberLimit;
        ++PotentialAbundantNumber)
    {
        if(IsAbundant(PotentialAbundantNumber))
        {
            buffer_push(List, PotentialAbundantNumber);
        }
    }

    AbundantNumberList.List = List;
    AbundantNumberList.Length = buffer_count(List);
}
예제 #28
0
파일: uart.c 프로젝트: InnitApps/RocketPack
__interrupt void USCI_A1_ISR(void)
{
  switch(__even_in_range(UCA1IV,0x08))
  {
  case 0:							// Vector 0 - no interrupt
	  break;
  case 2:                           // Vector 2 - RXIFG
	    db_byte = UCA1RXBUF;
	    dbRXERROR = buffer_push(db_byte, &db_rx_buffer);
	    //radio_send_byte(db_byte);
	    if (db_rx_buffer.packets_rxd) LPM0_EXIT;
	  break;
  case 4:    						// Vector 4 - TXIFG
	  break;
  case 8:
	  break;
  default:
	  break;
  }
}
예제 #29
0
파일: lbuffer.c 프로젝트: nan1888/lask
/*
** self = buffer:putreader(rd, offset=0, length=all)
*/
static int lbuffer_putreader(lua_State *L) 
{
	Buffer *buffer = buffer_lcheck(L, 1);
	Reader *reader = reader_lcheck(L, 2);
	size_t offset = (size_t)luaL_optint(L, 3, 0);
	size_t length = reader->datasiz;
	
	if (lua_gettop(L) >= 4) 
		length = (size_t)luaL_checkint(L, 4);
	
	if (offset >= reader->datasiz)
		length = 0;
	else if ((offset + length) > reader->datasiz)
		length = (reader->datasiz - offset);
		
	if (length > 0)
		buffer_push(buffer, reader->data + offset, length);
		
	lua_pushvalue(L, 1);
	return 1;
}
예제 #30
0
END_TEST


/**
 * Ensure that the fixed_delay distribution works by sending a number of packets
 * spaced widely apart and ensuring all get the same delay.
 */
START_TEST (test_fixed_delay)
{
	INIT_CON();
	SET_CON_FIXED_DELAY(INTERVAL);
	
	for (int i = 0; i < NUM_REPEATS; i++) {
		// Wait a little longer than the consumers delay before sending a packet
		// (this helps ensure that some counter isn't running in the background and
		// wrapping every INTERVAL or some such thing).
		for (int j = 0; j < INTERVAL+(INTERVAL/2); j++) {
			ck_assert_int_eq(packets_received, i);
			for (int k = 0; k < PERIOD; k++) {
				scheduler_tick_tock(&s);
			}
		}
		
		// Inject a packet
		buffer_push(&b, spinn_packet_pool_palloc(&pool));
		
		// The consumer should then accept the packet exactly after the interval has
		// ellapsed
		for (int j = 0; j < INTERVAL; j++) {
			ck_assert_int_eq(packets_received, i);
			for (int k = 0; k < PERIOD; k++) {
				scheduler_tick_tock(&s);
			}
		}
		
		// A packet should have been received by now
		ck_assert(buffer_is_empty(&b));
		ck_assert_int_eq(packets_received, i+1);
	}
}