fifo: add FIFO API test program, and fate test

Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
Stefano Sabatini 2011-07-16 09:49:42 +02:00 committed by Anton Khirnov
parent f2011ed234
commit 1717ba0cdd
4 changed files with 68 additions and 1 deletions

View File

@ -75,7 +75,7 @@ OBJS-$(ARCH_ARM) += arm/cpu.o
OBJS-$(ARCH_PPC) += ppc/cpu.o
OBJS-$(ARCH_X86) += x86/cpu.o
TESTPROGS = adler32 aes avstring base64 cpu crc des eval file lfg lls \
TESTPROGS = adler32 aes avstring base64 cpu crc des eval file fifo lfg lls \
md5 opt parseutils rational sha tree
TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo

View File

@ -127,3 +127,39 @@ void av_fifo_drain(AVFifoBuffer *f, int size)
f->rptr -= f->end - f->buffer;
f->rndx += size;
}
#ifdef TEST
#undef printf
int main(void)
{
/* create a FIFO buffer */
AVFifoBuffer *fifo = av_fifo_alloc(13 * sizeof(int));
int i, j, n;
/* fill data */
for (i = 0; av_fifo_space(fifo) >= sizeof(int); i++)
av_fifo_generic_write(fifo, &i, sizeof(int), NULL);
/* peek at FIFO */
n = av_fifo_size(fifo)/sizeof(int);
for (i = -n+1; i < n; i++) {
int *v = (int *)av_fifo_peek2(fifo, i*sizeof(int));
printf("%d: %d\n", i, *v);
}
printf("\n");
/* read data */
for (i = 0; av_fifo_size(fifo) >= sizeof(int); i++) {
av_fifo_generic_read(fifo, &j, sizeof(int), NULL);
printf("%d ", j);
}
printf("\n");
av_fifo_free(fifo);
return 0;
}
#endif

View File

@ -25,6 +25,10 @@ FATE_TESTS += fate-eval
fate-eval: libavutil/eval-test$(EXESUF)
fate-eval: CMD = run libavutil/eval-test
FATE_TESTS += fate-fifo
fate-fifo: libavutil/fifo-test$(EXESUF)
fate-fifo: CMD = run libavutil/fifo-test
FATE_TESTS += fate-md5
fate-md5: libavutil/md5-test$(EXESUF)
fate-md5: CMD = run libavutil/md5-test

27
tests/ref/fate/fifo Normal file
View File

@ -0,0 +1,27 @@
-12: 1
-11: 2
-10: 3
-9: 4
-8: 5
-7: 6
-6: 7
-5: 8
-4: 9
-3: 10
-2: 11
-1: 12
0: 0
1: 1
2: 2
3: 3
4: 4
5: 5
6: 6
7: 7
8: 8
9: 9
10: 10
11: 11
12: 12
0 1 2 3 4 5 6 7 8 9 10 11 12