diff options
author | Ian Moffett <ian@osmora.org> | 2024-03-07 17:28:52 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-03-07 18:24:51 -0500 |
commit | f5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch) | |
tree | 93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/tests/posix/popen.c | |
parent | bd5969fc876a10b18613302db7087ef3c40f18e1 (diff) |
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/tests/posix/popen.c')
-rw-r--r-- | lib/mlibc/tests/posix/popen.c | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/lib/mlibc/tests/posix/popen.c b/lib/mlibc/tests/posix/popen.c deleted file mode 100644 index 87bbde2..0000000 --- a/lib/mlibc/tests/posix/popen.c +++ /dev/null @@ -1,42 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <assert.h> -#include <unistd.h> - -#ifdef USE_HOST_LIBC -#define TEST_FILE "popen-host-libc.tmp" -#else -#define TEST_FILE "popen.tmp" -#endif - -#define TEST_STRING1 "the quick brown fox jumps over the lazy dog" -#define TEST_STRING1_LEN 43 -#define TEST_STRING2 "Lorem ipsum dolor sit amet, consectetur adipiscing elit" -#define TEST_STRING2_LEN 55 - -int main() { - // Test reading - FILE *f1 = popen("echo -n '" TEST_STRING1 "'", "r"); - assert(f1); - char buf1[TEST_STRING1_LEN]; - assert(fread(buf1, 1, TEST_STRING1_LEN, f1) == TEST_STRING1_LEN); - assert(memcmp(buf1, TEST_STRING1, TEST_STRING1_LEN) == 0); - pclose(f1); - - // Test writing - FILE *f2 = popen("cat - > " TEST_FILE, "w"); - assert(f2); - assert(fwrite(TEST_STRING2, 1, TEST_STRING2_LEN, f2) == TEST_STRING2_LEN); - pclose(f2); - - // Read test file back - FILE *test_file = fopen(TEST_FILE, "r"); - assert(test_file); - char buf2[TEST_STRING2_LEN]; - assert(fread(buf2, 1, TEST_STRING2_LEN, test_file) == TEST_STRING2_LEN); - assert(memcmp(buf2, TEST_STRING2, TEST_STRING2_LEN) == 0); - fclose(test_file); - assert(unlink(TEST_FILE) == 0); - - return 0; -} |