mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 16:39:43 +00:00
Update nbio test
This commit is contained in:
parent
d1ad5c336e
commit
6d0101d118
@ -4,6 +4,13 @@ LIBRETRO_COMM_DIR := ../../..
|
||||
|
||||
SOURCES := \
|
||||
nbio_test.c \
|
||||
$(LIBRETRO_COMM_DIR)/compat/fopen_utf8.c \
|
||||
$(LIBRETRO_COMM_DIR)/compat/compat_strl.c \
|
||||
$(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_intf.c \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_linux.c \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_unixmmap.c \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_windowsmmap.c \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_stdio.c
|
||||
|
||||
OBJS := $(SOURCES:.c=.o)
|
||||
|
@ -10,21 +10,22 @@ static void nbio_write_test(void)
|
||||
void* ptr = NULL;
|
||||
struct nbio_t* write = nbio_open("test.bin", NBIO_WRITE);
|
||||
if (!write)
|
||||
puts("ERROR: nbio_open failed (1)");
|
||||
puts("[ERROR]: nbio_open failed (1)");
|
||||
|
||||
nbio_resize(write, 1024*1024);
|
||||
|
||||
ptr = nbio_get_ptr(write, &size);
|
||||
if (size != 1024*1024)
|
||||
puts("ERROR: wrong size (1)");
|
||||
puts("[ERROR]: wrong size (1)");
|
||||
|
||||
memset(ptr, 0x42, 1024*1024);
|
||||
nbio_begin_write(write);
|
||||
|
||||
while (!nbio_iterate(write)) looped=true;
|
||||
while (!nbio_iterate(write))
|
||||
looped=true;
|
||||
|
||||
if (!looped)
|
||||
puts("Write finished immediately?");
|
||||
puts("[SUCCESS]: Write finished immediately.");
|
||||
|
||||
nbio_free(write);
|
||||
}
|
||||
@ -36,26 +37,27 @@ static void nbio_read_test(void)
|
||||
struct nbio_t* read = nbio_open("test.bin", NBIO_READ);
|
||||
void* ptr = nbio_get_ptr(read, &size);
|
||||
if (!read)
|
||||
puts("ERROR: nbio_open failed (2)");
|
||||
puts("[ERROR]: nbio_open failed (2)");
|
||||
|
||||
if (size != 1024*1024)
|
||||
puts("ERROR: wrong size (2)");
|
||||
puts("[ERROR]: wrong size (2)");
|
||||
if (ptr)
|
||||
puts("Read pointer is available before iterating?");
|
||||
puts("[SUCCESS]: Read pointer is available before iterating.");
|
||||
|
||||
nbio_begin_read(read);
|
||||
|
||||
while (!nbio_iterate(read)) looped=true;
|
||||
while (!nbio_iterate(read))
|
||||
looped=true;
|
||||
|
||||
if (!looped)
|
||||
puts("Read finished immediately?");
|
||||
puts("[SUCCESS]: Read finished immediately.");
|
||||
|
||||
ptr = nbio_get_ptr(read, &size);
|
||||
|
||||
if (size != 1024*1024)
|
||||
puts("ERROR: wrong size (3)");
|
||||
puts("[ERROR]: wrong size (3)");
|
||||
if (*(char*)ptr != 0x42 || memcmp(ptr, (char*)ptr+1, 1024*1024-1))
|
||||
puts("ERROR: wrong data");
|
||||
puts("[ERROR]: wrong data");
|
||||
|
||||
nbio_free(read);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user