Lines Matching full:io
13 #include <api/io.h>
59 size_t buf_size, struct io *io) in setup_test() argument
64 io->fd = open(path, O_RDONLY); in setup_test()
65 if (io->fd < 0) { in setup_test()
70 io->buf = malloc(buf_size); in setup_test()
71 if (io->buf == NULL) { in setup_test()
73 close(io->fd); in setup_test()
77 io__init(io, io->fd, io->buf, buf_size); in setup_test()
81 static void cleanup_test(char path[PATH_MAX], struct io *io) in cleanup_test() argument
83 zfree(&io->buf); in cleanup_test()
84 close(io->fd); in cleanup_test()
91 struct io io; in do_test_get_char() local
95 if (setup_test(path, test_string, buf_size, &io)) in do_test_get_char()
99 ch = io__get_char(&io); in do_test_get_char()
102 EXPECT_EQUAL(io.eof, false); in do_test_get_char()
104 ch = io__get_char(&io); in do_test_get_char()
106 EXPECT_EQUAL(io.eof, true); in do_test_get_char()
108 cleanup_test(path, &io); in do_test_get_char()
138 struct io io; in do_test_get_hex() local
142 if (setup_test(path, test_string, 4, &io)) in do_test_get_hex()
145 ch = io__get_hex(&io, &hex); in do_test_get_hex()
149 ch = io__get_hex(&io, &hex); in do_test_get_hex()
153 ch = io__get_hex(&io, &hex); in do_test_get_hex()
157 EXPECT_EQUAL(io.eof, end_eof); in do_test_get_hex()
159 cleanup_test(path, &io); in do_test_get_hex()
219 struct io io; in do_test_get_dec() local
223 if (setup_test(path, test_string, 4, &io)) in do_test_get_dec()
226 ch = io__get_dec(&io, &dec); in do_test_get_dec()
230 ch = io__get_dec(&io, &dec); in do_test_get_dec()
234 ch = io__get_dec(&io, &dec); in do_test_get_dec()
238 EXPECT_EQUAL(io.eof, end_eof); in do_test_get_dec()
240 cleanup_test(path, &io); in do_test_get_dec()
296 struct io io; in test_get_line() local
310 if (setup_test(path, test_string, buf_size, &io)) in test_get_line()
313 EXPECT_EQUAL((int)io__getline(&io, &line, &line_len), 513); in test_get_line()
318 EXPECT_EQUAL((int)io__getline(&io, &line, &line_len), 510); in test_get_line()
323 cleanup_test(path, &io); in test_get_line()
343 DEFINE_SUITE("Test api io", api_io);