path
stringlengths
14
112
content
stringlengths
0
6.32M
size
int64
0
6.32M
max_lines
int64
1
100k
repo_name
stringclasses
2 values
autogenerated
bool
1 class
cosmopolitan/test/libc/log/test.mk
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ #───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ PKGS += TEST_LIBC_LOG TEST_LIBC_LOG_SRCS := $(wildcard test/libc/log/*.c) TEST_LIBC_LOG_SRCS_TEST = $(filter %_test.c,$(TEST_LIBC_LOG_SRCS)) TEST_LIBC_LOG_OBJS = \ $(TEST_LIBC_LOG_SRCS:%.c=o/$(MODE)/%.o) \ o/$(MODE)/test/libc/log/backtrace.com.zip.o \ o/$(MODE)/test/libc/log/backtrace.com.dbg.zip.o TEST_LIBC_LOG_COMS = \ $(TEST_LIBC_LOG_SRCS:%.c=o/$(MODE)/%.com) TEST_LIBC_LOG_BINS = \ $(TEST_LIBC_LOG_COMS) \ $(TEST_LIBC_LOG_COMS:%=%.dbg) TEST_LIBC_LOG_TESTS = \ $(TEST_LIBC_LOG_SRCS_TEST:%.c=o/$(MODE)/%.com.ok) TEST_LIBC_LOG_CHECKS = \ $(TEST_LIBC_LOG_SRCS_TEST:%.c=o/$(MODE)/%.com.runs) TEST_LIBC_LOG_DIRECTDEPS = \ LIBC_CALLS \ LIBC_RUNTIME \ NET_HTTP \ LIBC_STDIO \ LIBC_X \ LIBC_INTRIN \ LIBC_FMT \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_LOG \ LIBC_STR \ LIBC_STUBS \ LIBC_TESTLIB \ LIBC_SYSV \ LIBC_LOG \ LIBC_ZIPOS TEST_LIBC_LOG_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_LOG_DIRECTDEPS),$($(x)))) o/$(MODE)/test/libc/log/log.pkg: \ $(TEST_LIBC_LOG_OBJS) \ $(foreach x,$(TEST_LIBC_LOG_DIRECTDEPS),$($(x)_A).pkg) o/$(MODE)/test/libc/log/%.com.dbg: \ $(TEST_LIBC_LOG_DEPS) \ o/$(MODE)/test/libc/log/%.o \ o/$(MODE)/test/libc/log/log.pkg \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) o/$(MODE)/test/libc/log/backtrace_test.com.dbg: \ $(TEST_LIBC_LOG_DEPS) \ o/$(MODE)/test/libc/log/backtrace.com.zip.o \ o/$(MODE)/test/libc/log/backtrace.com.dbg.zip.o \ o/$(MODE)/test/libc/log/backtrace_test.o \ o/$(MODE)/test/libc/log/log.pkg \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) o/$(MODE)/test/libc/log/backtrace.com.dbg: \ $(TEST_LIBC_LOG_DEPS) \ o/$(MODE)/test/libc/log/backtrace.o \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) o/$(MODE)/test/libc/log/backtrace.com.zip.o \ o/$(MODE)/test/libc/log/backtrace.com.dbg.zip.o: private \ ZIPOBJ_FLAGS += \ -B .PHONY: o/$(MODE)/test/libc/log o/$(MODE)/test/libc/log: \ $(TEST_LIBC_LOG_BINS) \ $(TEST_LIBC_LOG_CHECKS)
2,371
88
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/posix_spawn_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/posix_spawn.h" #include "libc/atomic.h" #include "libc/calls/calls.h" #include "libc/calls/state.internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/dce.h" #include "libc/fmt/conv.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/safemacros.internal.h" #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" #ifdef __x86_64__ char testlib_enable_tmp_setup_teardown; __attribute__((__constructor__)) static void init(void) { switch (atoi(nulltoempty(getenv("THE_DOGE")))) { case 42: exit(42); default: break; } } TEST(posix_spawn, test) { int rc, ws, pid; char *prog = GetProgramExecutableName(); char *args[] = {prog, NULL}; char *envs[] = {"THE_DOGE=42", NULL}; EXPECT_EQ(0, posix_spawn(&pid, prog, NULL, NULL, args, envs)); EXPECT_NE(-1, waitpid(pid, &ws, 0)); EXPECT_TRUE(WIFEXITED(ws)); EXPECT_EQ(42, WEXITSTATUS(ws)); } TEST(posix_spawn, pipe) { char buf[10]; int p[2], pid, status; const char *pn = "./echo.com"; posix_spawn_file_actions_t fa; testlib_extract("/zip/echo.com", "echo.com", 0755); ASSERT_SYS(0, 0, pipe(p)); ASSERT_EQ(0, posix_spawn_file_actions_init(&fa)); ASSERT_EQ(0, posix_spawn_file_actions_addclose(&fa, p[0])); ASSERT_EQ(0, posix_spawn_file_actions_adddup2(&fa, p[1], 1)); ASSERT_EQ(0, posix_spawn_file_actions_addclose(&fa, p[1])); ASSERT_EQ(0, posix_spawnp(&pid, pn, &fa, 0, (char *[]){pn, "hello", 0}, 0)); ASSERT_SYS(0, 0, close(p[1])); ASSERT_SYS(0, pid, waitpid(pid, &status, 0)); ASSERT_SYS(0, 6, read(p[0], buf, sizeof(buf))); ASSERT_SYS(0, 0, close(p[0])); ASSERT_EQ(0, posix_spawn_file_actions_destroy(&fa)); } _Thread_local atomic_int gotsome; void OhMyGoth(int sig) { ++gotsome; } // time for a vfork() clone() signal bloodbath TEST(posix_spawn, torture) { int n = 10; int ws, pid; short flags; sigset_t allsig; posix_spawnattr_t attr; posix_spawn_file_actions_t fa; signal(SIGUSR2, OhMyGoth); sigfillset(&allsig); if (!fileexists("echo.com")) { testlib_extract("/zip/echo.com", "echo.com", 0755); } // XXX: NetBSD doesn't seem to let us set the scheduler to itself ;_; ASSERT_EQ(0, posix_spawnattr_init(&attr)); ASSERT_EQ(0, posix_spawnattr_setflags( &attr, POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_SETSIGMASK | (IsLinux() ? POSIX_SPAWN_SETSCHEDULER : 0))); ASSERT_EQ(0, posix_spawnattr_setsigmask(&attr, &allsig)); ASSERT_EQ(0, posix_spawnattr_setsigdefault(&attr, &allsig)); ASSERT_EQ(0, posix_spawn_file_actions_init(&fa)); ASSERT_EQ(0, posix_spawn_file_actions_addclose(&fa, 0)); ASSERT_EQ( 0, posix_spawn_file_actions_addopen(&fa, 1, "/dev/null", O_WRONLY, 0644)); ASSERT_EQ(0, posix_spawn_file_actions_adddup2(&fa, 1, 0)); for (int i = 0; i < n; ++i) { char *volatile zzz = malloc(13); volatile int fd = open("/dev/null", O_WRONLY); char *args[] = {"./echo.com", NULL}; char *envs[] = {NULL}; raise(SIGUSR2); ASSERT_EQ(0, posix_spawn(&pid, "./echo.com", &fa, &attr, args, envs)); ASSERT_FALSE(__vforked); ASSERT_NE(-1, waitpid(pid, &ws, 0)); ASSERT_TRUE(WIFEXITED(ws)); ASSERT_EQ(0, WEXITSTATUS(ws)); close(fd); free(zzz); } // TODO(jart): Why does it deliver 2x the signals sometimes? ASSERT_NE(0, gotsome); ASSERT_EQ(0, posix_spawn_file_actions_destroy(&fa)); ASSERT_EQ(0, posix_spawnattr_destroy(&attr)); } void *Torturer(void *arg) { posix_spawn_torture(); return 0; } TEST(posix_spawn, agony) { int i, n = 3; pthread_t *t = _gc(malloc(sizeof(pthread_t) * n)); testlib_extract("/zip/echo.com", "echo.com", 0755); for (i = 0; i < n; ++i) { ASSERT_EQ(0, pthread_create(t + i, 0, Torturer, 0)); } for (i = 0; i < n; ++i) { ASSERT_EQ(0, pthread_join(t[i], 0)); } } /* * BEST LINUX FORK+EXEC+EXIT+WAIT PERFORMANCE * The fastest it can go with fork() is 40µs * The fastest it can go with vfork() is 26µs */ void BenchmarkProcessLifecycle(void) { int rc, ws, pid; char *prog = "/tmp/tiny64"; char *args[] = {"tiny64", NULL}; char *envs[] = {NULL}; ASSERT_EQ(0, posix_spawn(&pid, prog, NULL, NULL, args, envs)); ASSERT_NE(-1, waitpid(pid, &ws, 0)); ASSERT_TRUE(WIFEXITED(ws)); ASSERT_EQ(42, WEXITSTATUS(ws)); } const char kTinyLinuxExit[128] = { 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, // ⌂ELF☻☺☺  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //          0x02, 0x00, 0x3e, 0x00, 0x01, 0x00, 0x00, 0x00, // ☻ > ☺    0x78, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, // x @      0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // @        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //          0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x38, 0x00, //     @ 8  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ☺        0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, // ☺   ♣    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //          0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, //   @      0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, //   @      0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Ç        0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Ç        0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //  ►       0x6a, 0x2a, 0x5f, 0x6a, 0x3c, 0x58, 0x0f, 0x05, // j*_j<X☼♣ }; /* BENCH(spawn, bench) { */ /* int fd; */ /* if (IsLinux()) { */ /* fd = open("/tmp/tiny64", O_CREAT | O_TRUNC | O_WRONLY, 0755); */ /* write(fd, kTinyLinuxExit, 128); */ /* close(fd); */ /* EZBENCH2("spawn", donothing, BenchmarkProcessLifecycle()); */ /* unlink("/tmp/tiny64"); */ /* } */ /* } */ #endif /* __x86_64__ */
8,047
199
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/dtoa_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/struct/sched_param.h" #include "libc/dce.h" #include "libc/fmt/fmt.h" #include "libc/macros.internal.h" #include "libc/math.h" #include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/vendor.internal.h" #include "libc/runtime/internal.h" #include "libc/runtime/stack.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/clone.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/prot.h" #include "libc/sysv/consts/sched.h" #include "libc/testlib/testlib.h" #include "libc/thread/spawn.h" #include "libc/thread/wait0.internal.h" #include "libc/x/x.h" #define DUB(i) (union Dub){i}.x #define DUBBLE(a, b, c, d, e) \ { \ { 0x##e, 0x##d, 0x##c, 0x##b, 0x##a } \ } char buf[128]; union Dub { uint64_t i; double x; }; void SetUpOnce(void) { __enable_threads(); ASSERT_SYS(0, 0, pledge("stdio", 0)); } int Worker(void *p, int tid) { int i; char str[64]; for (i = 0; i < 256; ++i) { bzero(str, sizeof(str)); snprintf(str, sizeof(str), "%.15g", atan2(-1., -.5)); ASSERT_STREQ("-2.0344439357957", str); } return 0; } TEST(dtoa, locks) { int i, n = 32; struct spawn *t = gc(malloc(sizeof(struct spawn) * n)); for (i = 0; i < n; ++i) ASSERT_SYS(0, 0, _spawn(Worker, 0, t + i)); for (i = 0; i < n; ++i) EXPECT_SYS(0, 0, _join(t + i)); } static const struct { uint64_t i; const char *f; const char *s; } Vd[] = { {0x3ff3ae147ae147ae, "%.8a", "0x1.3ae147aep+0"}, // {0x3ff3ae147ae147ae, "%.7a", "0x1.3ae147bp+0"}, // {0x3ff3ae147ae147ae, "%.2a", "0x1.3bp+0"}, // }; TEST(printf, double) { int i; for (i = 0; i < ARRAYLEN(Vd); ++i) { ++g_testlib_ran; snprintf(buf, sizeof(buf), Vd[i].f, DUB(Vd[i].i)); if (strcmp(Vd[i].s, buf)) { fprintf(stderr, "TEST FAILED\n" "EXPECT_STREQ(%`'s, FMT(%`'s, DUB(0x%016lx)))\n" " BUT GOT %`'s\n", Vd[i].s, Vd[i].f, Vd[i].i, buf); testlib_incrementfailed(); } } } #if LDBL_MANT_DIG == 64 static const struct { const char *s; const char *f; union { uint16_t i[5]; long double x; } u; } Vx[] = { {"1.23000000000000000002", "%.21Lg", DUBBLE(3fff, 9d70, a3d7, a3d, 70a4)}, {"123000000000000000000", "%.21Lg", DUBBLE(4041, d55e, f90a, 2da1, 8000)}, {"1.22999999999999999997e-20", "%.21Lg", DUBBLE(3fbc, e857, 267b, b3a9, 84f2)}, {"1.23456789000000000003", "%.21Lg", DUBBLE(3fff, 9e06, 5214, 1ef0, dbf6)}, {"123456589000000000000", "%.21Lg", DUBBLE(4041, d629, bd33, 5cc, ba00)}, {"1.22999999999999999999e+30", "%.21Lg", DUBBLE(4062, f865, 8274, 7dbc, 824a)}, {"1.22999999999999999999e-30", "%.21Lg", DUBBLE(3f9b, c794, 337a, 8085, 54eb)}, {"1.23456788999999999998e-20", "%.21Lg", DUBBLE(3fbc, e934, a38, f3d6, d352)}, {"1.23456788999999999999e-30", "%.21Lg", DUBBLE(3f9b, c851, f19d, decc, a8fc)}, {"1.23456789012345678899", "%.21Lg", DUBBLE(3fff, 9e06, 5214, 62cf, db8d)}, {"1.22999999999999999997e+306", "%.21Lg", DUBBLE(43f7, e033, b668, e30f, a6d5)}, {"1.23000000000000000002e-306", "%.21Lg", DUBBLE(3c06, dd1d, c2ed, 1cb7, 3f25)}, {"1.23000000000000000002e-320", "%.21Lg", DUBBLE(3bd8, 9b98, c371, 844c, 3f1a)}, {"0xap-3", "%.La", DUBBLE(3fff, 9d70, a3d7, a3d, 70a4)}, {"0x9.d70a3d70a3d70a4p-3", "%.20La", DUBBLE(3fff, 9d70, a3d7, a3d, 70a4)}, {"0x9.b18ab5df7180b6cp+88", "%La", DUBBLE(405a, 9b18, ab5d, f718, b6c)}, {"0xa.fc6a015291b4024p+87", "%La", DUBBLE(4059, afc6, a015, 291b, 4024)}, }; TEST(printf, longdouble) { if (IsGenuineBlink()) { return; // TODO(jart): long double precision in blink } int i; for (i = 0; i < ARRAYLEN(Vx); ++i) { ++g_testlib_ran; snprintf(buf, sizeof(buf), Vx[i].f, Vx[i].u.x); if (strcmp(Vx[i].s, buf)) { fprintf(stderr, "TEST FAILED\n" "\t{%`'s, %`'s, DUBBLE(%x, %x, %x, %x, %x)}\n" "\t→%`'s\n", Vx[i].s, Vx[i].f, Vx[i].u.i[0], Vx[i].u.i[1], Vx[i].u.i[2], Vx[i].u.i[3], Vx[i].u.i[4], buf); testlib_incrementfailed(); } } } #endif // LDBL_MANT_DIG == 64
6,133
162
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/iconv_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" #include "libc/stdio/iconv.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" TEST(iconv, test) { iconv_t cd; char buf[32] = {0}; char *in = "\xB6\xE2ʸ\xC2\xCE"; size_t inb = strlen(in); char *out = buf; size_t outb = sizeof(buf); ASSERT_NE((iconv_t)-1, (cd = iconv_open("UTF-8", "EUC-JP"))); EXPECT_EQ(0, iconv(cd, &in, &inb, &out, &outb)); EXPECT_STREQ("", in); EXPECT_STREQ("金文体", buf); ASSERT_EQ(0, iconv_close(cd)); }
2,391
39
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/vappendf_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" #include "libc/mem/mem.h" #include "libc/stdio/append.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" TEST(vappendf, test) { char *b = 0; ASSERT_NE(-1, appendf(&b, "hello ")); EXPECT_EQ(6, appendz(b).i); EXPECT_EQ(0, b[appendz(b).i]); EXPECT_EQ(6, strlen(b)); // guarantees nul terminator ASSERT_NE(-1, appendf(&b, " world\n")); EXPECT_EQ(13, appendz(b).i); EXPECT_EQ(0, b[appendz(b).i]); EXPECT_EQ(13, strlen(b)); ASSERT_NE(-1, appendd(&b, "\0", 1)); // supports binary EXPECT_EQ(14, appendz(b).i); EXPECT_EQ(0, b[appendz(b).i]); EXPECT_EQ(13, strlen(b)); EXPECT_EQ(0, b[13]); EXPECT_EQ(0, b[14]); EXPECT_STREQ("hello world\n", b); free(b); } TEST(appends, test) { char *b = 0; ASSERT_NE(-1, appends(&b, "")); EXPECT_NE(0, b); EXPECT_EQ(0, appendz(b).i); EXPECT_EQ(0, b[appendz(b).i]); ASSERT_NE(-1, appends(&b, "hello ")); EXPECT_EQ(6, appendz(b).i); EXPECT_EQ(0, b[appendz(b).i]); EXPECT_EQ(6, strlen(b)); // guarantees nul terminator ASSERT_NE(-1, appends(&b, " world\n")); EXPECT_EQ(13, appendz(b).i); EXPECT_EQ(13, strlen(b)); EXPECT_EQ(0, b[13]); EXPECT_STREQ("hello world\n", b); free(b); } TEST(appendd, test) { char *b = 0; ASSERT_NE(-1, appendd(&b, 0, 0)); EXPECT_NE(0, b); EXPECT_EQ(0, appendz(b).i); EXPECT_EQ(0, b[appendz(b).i]); ASSERT_NE(-1, appendd(&b, "hello ", 6)); EXPECT_EQ(6, appendz(b).i); EXPECT_EQ(0, b[appendz(b).i]); EXPECT_EQ(6, strlen(b)); // guarantees nul terminator ASSERT_NE(-1, appendd(&b, " world\n", 7)); EXPECT_EQ(13, appendz(b).i); EXPECT_EQ(13, strlen(b)); EXPECT_EQ(0, b[13]); EXPECT_STREQ("hello world\n", b); free(b); } TEST(appendw, test) { char *b = 0; ASSERT_NE(-1, appendw(&b, 0)); EXPECT_EQ(1, appendz(b).i); EXPECT_EQ(0, b[0]); EXPECT_EQ(0, b[1]); ASSERT_NE(-1, appendw(&b, 'h')); EXPECT_EQ(2, appendz(b).i); EXPECT_EQ(0, b[0]); EXPECT_EQ('h', b[1]); EXPECT_EQ(0, b[2]); ASSERT_NE(-1, appendw(&b, READ64LE("ello!\0\0"))); EXPECT_EQ(7, appendz(b).i); EXPECT_EQ(0, b[0]); EXPECT_EQ('h', b[1]); EXPECT_EQ('e', b[2]); EXPECT_EQ('l', b[3]); EXPECT_EQ('l', b[4]); EXPECT_EQ('o', b[5]); EXPECT_EQ('!', b[6]); EXPECT_EQ(0, b[7]); free(b); } TEST(appendr, testShrink_nulTerminates) { char *b = 0; ASSERT_NE(-1, appends(&b, "hello")); EXPECT_EQ(5, appendz(b).i); ASSERT_NE(-1, appendr(&b, 1)); EXPECT_EQ(0, strcmp(b, "h")); EXPECT_EQ(1, appendz(b).i); ASSERT_NE(-1, appendr(&b, 0)); EXPECT_EQ(0, appendz(b).i); EXPECT_EQ(0, strcmp(b, "")); ASSERT_NE(-1, appendr(&b, 5)); EXPECT_EQ(0, b[0]); EXPECT_EQ(0, b[1]); EXPECT_EQ(0, b[2]); EXPECT_EQ(0, b[3]); EXPECT_EQ(0, b[4]); EXPECT_EQ(0, b[5]); free(b); } TEST(appendr, testExtend_zeroFills) { char *b = 0; ASSERT_NE(-1, appends(&b, "hello")); EXPECT_EQ(5, appendz(b).i); ASSERT_NE(-1, appendr(&b, 20)); EXPECT_EQ(20, appendz(b).i); ASSERT_BINEQ(u"hello                ", b); ASSERT_NE(-1, appendr(&b, 20)); EXPECT_EQ(20, appendz(b).i); ASSERT_BINEQ(u"hello                ", b); free(b); } TEST(appendr, testAbsent_allocatesNul) { char *b = 0; ASSERT_NE(-1, appendr(&b, 0)); ASSERT_BINEQ(u" ", b); EXPECT_EQ(0, appendz(b).i); ASSERT_BINEQ(u" ", b); free(b); } TEST(appendd, testMemFail_doesntInitializePointer) { char *b = 0; ASSERT_EQ(-1, appendd(&b, 0, -1ull >> 8)); EXPECT_EQ(0, b); } TEST(appendd, testMemFail_doesntFreeExistingAllocation) { char *b = 0; ASSERT_NE(-1, appends(&b, "hello")); EXPECT_STREQ("hello", b); ASSERT_EQ(-1, appendd(&b, 0, -1ull >> 7)); EXPECT_STREQ("hello", b); free(b); } TEST(appendd, nontrivialAmountOfMemory) { char *b = 0; int i, n = 40000; for (i = 0; i < n; ++i) { ASSERT_EQ(2, appendd(&b, "hi", 2)); } EXPECT_EQ(40000 * 2, appendz(b).i); free(b); } BENCH(vappendf, bench) { const char t[] = {0}; char *b = 0; EZBENCH2("appendf", donothing, appendf(&b, "hello")); EZBENCH2("kappendf", donothing, kappendf(&b, "hello")); free(b), b = 0; EZBENCH2("appends", donothing, appends(&b, "hello")); free(b), b = 0; EZBENCH2("appendw", donothing, appendw(&b, 'h' | 'e' << 8 | 'l' << 16 | 'l' << 24 | (uint64_t)'o' << 32)); free(b), b = 0; EZBENCH2("appendd", donothing, appendd(&b, "hello", 5)); EZBENCH2("appendr", donothing, appendr(&b, 0)); free(b), b = 0; }
6,338
189
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/fgetln_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" #include "libc/x/xgetline.h" TEST(fgetln, test) { FILE *f; f = fmemopen(_gc(strdup(kHyperion)), kHyperionSize, "r+"); EXPECT_STREQ("The fall of Hyperion - a Dream\n", fgetln(f, 0)); EXPECT_STREQ("John Keats\n", fgetln(f, 0)); EXPECT_STREQ("\n", fgetln(f, 0)); fclose(f); } TEST(fgetln, testGoodLastLine) { FILE *f; size_t n; f = fmemopen("foo\nbar\n", 8, "r"); EXPECT_STREQ("foo\n", fgetln(f, &n)); EXPECT_EQ(4, n); EXPECT_STREQ("bar\n", fgetln(f, &n)); EXPECT_EQ(4, n); EXPECT_EQ(NULL, fgetln(f, 0)); EXPECT_FALSE(ferror(f)); EXPECT_TRUE(feof(f)); fclose(f); } TEST(fgetln, testEvilLastLine) { FILE *f; f = fmemopen("foo\nbar", 7, "r"); EXPECT_STREQ("foo\n", fgetln(f, 0)); EXPECT_STREQ("bar", fgetln(f, 0)); EXPECT_EQ(NULL, fgetln(f, 0)); EXPECT_FALSE(ferror(f)); EXPECT_TRUE(feof(f)); fclose(f); } TEST(fgetln, testReadingFromStdin_doesntLeakMemory) { FILE *f; int oldstdin, pfds[2]; oldstdin = dup(0); EXPECT_SYS(0, 0, pipe(pfds)); EXPECT_SYS(0, 8, write(pfds[1], "foo\nbar\n", 8)); EXPECT_SYS(0, 0, close(pfds[1])); EXPECT_SYS(0, 0, close(0)); EXPECT_SYS(0, 0, dup(pfds[0])); EXPECT_SYS(0, 0, close(pfds[0])); EXPECT_STREQ("foo\n", fgetln(stdin, 0)); EXPECT_STREQ("bar\n", fgetln(stdin, 0)); EXPECT_EQ(NULL, fgetln(stdin, 0)); EXPECT_FALSE(ferror(stdin)); EXPECT_TRUE(feof(stdin)); EXPECT_SYS(0, 0, close(0)); EXPECT_SYS(0, 0, dup(oldstdin)); clearerr(stdin); } BENCH(fgetln, bench) { FILE *f = fmemopen(_gc(strdup(kHyperion)), kHyperionSize, "r+"); EZBENCH2("fgetln", donothing, fgetln(f, 0)); EZBENCH2("xgetline", donothing, free(xgetline(f))); fclose(f); }
3,738
89
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/devrand_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/mem/gc.internal.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" TEST(getrandom, test) { void *A = gc(calloc(1, 8)); void *B = gc(calloc(1, 8)); EXPECT_EQ(8, getrandom(A, 8, 0)); EXPECT_EQ(8, getrandom(B, 8, 0)); EXPECT_BINNE(u"        ", A); EXPECT_BINNE(u"        ", B); EXPECT_NE(0, memcmp(A, B, 8)); }
2,279
35
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/fseeko_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" char testlib_enable_tmp_setup_teardown; TEST(fseeko, test) { FILE *f; EXPECT_SYS(0, 0, xbarf("foo", "hello!", 6)); EXPECT_NE(NULL, (f = fopen("foo", "r"))); EXPECT_EQ(0, fseeko(f, -3, SEEK_END)); EXPECT_EQ('l', fgetc(f)); EXPECT_EQ('o', fgetc(f)); EXPECT_EQ(0, fseeko(f, 3, SEEK_SET)); EXPECT_EQ('l', fgetc(f)); EXPECT_EQ('o', fgetc(f)); EXPECT_EQ(0, fclose(f)); }
2,339
38
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/ungetc_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" FILE *f; char buf[512]; char testlib_enable_tmp_setup_teardown; TEST(ungetc, testGetChar_canBeUndoneWithinReason) { ASSERT_NE(NULL, (f = fopen("hog", "wb"))); EXPECT_EQ(12, fputs("hello world\n", f)); EXPECT_NE(-1, fputs(kHyperion, f)); EXPECT_EQ(0, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ('h', fgetc(f)); EXPECT_EQ('e', fgetc(f)); EXPECT_EQ('e', ungetc('e', f)); EXPECT_EQ('h', ungetc('h', f)); EXPECT_EQ(5, fread(buf, 1, 5, f)); EXPECT_BINEQ(u"hello", buf); EXPECT_EQ(0, fclose(f)); } TEST(ungetc, testRead_canBeUndoneWithinReason) { ASSERT_NE(NULL, (f = fopen("hog", "wb"))); EXPECT_EQ(12, fputs("hello world\n", f)); EXPECT_EQ(0, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ(3, fread(buf, 1, 3, f)); EXPECT_BINEQ(u"hel", buf); EXPECT_EQ('l', ungetc(buf[2], f)); EXPECT_EQ('e', ungetc(buf[1], f)); EXPECT_EQ(4, fread(buf, 1, 4, f)); EXPECT_BINEQ(u"ello", buf); EXPECT_EQ(0, fclose(f)); } TEST(ungetwc, testGetWideChar_canBeUndoneWithinReason) { memset(buf, 0, sizeof(buf)); ASSERT_NE(NULL, (f = fopen("hog", "wb"))); EXPECT_NE(-1, fputs("𐌰𐌱\n", f)); EXPECT_EQ(0, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ(L'𐌰', fgetwc(f)); EXPECT_EQ(L'𐌱', fgetwc(f)); EXPECT_EQ(L'𐌱', ungetwc(L'𐌱', f)); EXPECT_EQ(L'𐌰', ungetwc(L'𐌰', f)); EXPECT_NE(0, fread(buf, 1, sizeof(buf), f)); EXPECT_STREQ("𐌰𐌱\n", buf); EXPECT_EQ(0, fclose(f)); }
3,453
71
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/gz_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/o.h" #include "libc/testlib/testlib.h" #include "third_party/zlib/zlib.h" char testlib_enable_tmp_setup_teardown; TEST(gz, test) { int fd; gzFile f; char buf[64] = {0}; ASSERT_NE(NULL, (f = gzopen("hello.txt.gz", "wb"))); ASSERT_EQ(5, gzwrite(f, "hello", 5)); ASSERT_EQ(Z_OK, gzclose(f)); ASSERT_NE(NULL, (f = gzopen("hello.txt.gz", "rb"))); ASSERT_EQ(5, gzread(f, buf, sizeof(buf))); ASSERT_STREQ("hello", buf); ASSERT_EQ(Z_OK, gzclose(f)); ASSERT_NE(NULL, (fd = open("hello.txt.gz", O_RDONLY))); ASSERT_EQ(25, read(fd, buf, sizeof(buf))); EXPECT_BINEQ(u"▼ï◘      ♥╦H═╔╔• åª►6♣   ", buf); ASSERT_SYS(0, 0, close(fd)); }
2,610
46
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/dumphexc_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" #include "libc/stdio/hex.internal.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" TEST(DumpHexc, test) { EXPECT_STREQ("\"\\\n\ \\x68\\x65\\x6c\\x6c\\x6f\\xe2\\x86\\x92\\x0a\\x01\\x02\\x74\\x68\\x65\\x65\\x72\\\n\ \\x68\\x75\\x72\\x63\\x65\\x6f\\x61\\x68\\x72\\x63\\x75\\x6f\\x65\\x61\\x75\\x68\\\n\ \\x63\\x72\"", gc(DumpHexc("hello→\n\1\2theerhurceoahrcuoeauhcr", -1, 0))); } BENCH(DumpHexc, bench) { EZBENCH2("dumphexc", donothing, free(DumpHexc(kHyperion, kHyperionSize, 0))); }
2,459
37
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/ecvt_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" #include "libc/x/xasprintf.h" TEST(fcvt, test) { int decpt, sign; ASSERT_STREQ("3.14159265358979", _gc(xasprintf("%.14f", 3.14159265358979323846))); ASSERT_STREQ("3141592653589793", fcvt(3.14159265358979323846, 15, &decpt, &sign)); ASSERT_EQ(1, decpt); ASSERT_EQ(0, sign); }
2,259
34
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/fmemopen_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" TEST(fmemopen, testWriteRewindRead) { char c; FILE *f; f = fmemopen(NULL, BUFSIZ, "w+"); EXPECT_EQ(1, fwrite("c", 1, 1, f)); rewind(f); EXPECT_EQ(1, fread(&c, 1, 1, f)); EXPECT_EQ('c', c); fclose(f); } /* TEST(fmemopen, testWriteRead_readsNothingButNotEof) { */ /* char c; */ /* FILE *f; */ /* f = fmemopen(NULL, BUFSIZ, "w+"); */ /* EXPECT_EQ(1, fwrite("c", 1, 1, f)); */ /* EXPECT_EQ(0, fread(&c, 1, 1, f)); */ /* } */
2,349
40
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/crypt_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "third_party/musl/crypt.h" TEST(crypt, test) { // consistent with python crypt.crypt() EXPECT_STREQ("thXpd0YFlQG2w", crypt("hello", "there")); EXPECT_STREQ("$1$there$3B/lVCUlX8R18HDBuijby1", crypt("hello", "$1$there")); EXPECT_STREQ("$2aVOhEz8P7i6", crypt("hello", "$2$there")); EXPECT_STREQ("$5$there$.u5mdR0jvLs0jEf7qHTG98t8la1KVhEBH3eOFZ7ztL0", crypt("hello", "$5$there")); EXPECT_STREQ( "$6$there$y0TGuPcNSR23fFWCwYUj6VUfhnc9nlnkm6Y8waSLnANwCUcxK6esd7xm7.Jl." "jjr1/sPTaRK7igDNSxC.BhgX/", crypt("hello", "$6$there")); }
2,449
34
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/fgets_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" TEST(fgets, test) { FILE *f; char buf[29]; f = fmemopen(gc(strdup(kHyperion)), kHyperionSize, "r+"); ASSERT_STREQ("The fall of Hyperion - a Dre", fgets(buf, sizeof(buf), f)); ASSERT_STREQ("am\n", fgets(buf, sizeof(buf), f)); ASSERT_STREQ("John Keats\n", fgets(buf, sizeof(buf), f)); fclose(f); } TEST(fgets, eof) { FILE *f; char s[10]; char buf[] = "test"; ASSERT_NE(NULL, (f = fmemopen(buf, sizeof buf, "r"))); ASSERT_EQ(s, fgets(s, sizeof s, f)); ASSERT_EQ(0, strcmp(s, buf)); ASSERT_EQ(0, fgets(s, sizeof s, f)); ASSERT_EQ('t', s[0]); ASSERT_EQ(0, fclose(f)); } void Benchmark(void) { FILE *f; char *line; char buf[512]; f = fmemopen(gc(strdup(kHyperion)), kHyperionSize, "r+"); for (;;) { line = fgets(buf, sizeof(buf), f); if (!line) break; } fclose(f); } BENCH(fgets, bench) { EZBENCH2("fgets", donothing, Benchmark()); }
2,943
64
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/fwrite_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/struct/sigaction.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" #include "libc/time/time.h" #define PATH "hog" FILE *f; char buf[512]; char testlib_enable_tmp_setup_teardown; TEST(fwrite, test) { ASSERT_NE(NULL, (f = fopen(PATH, "wb"))); EXPECT_EQ(-1, fgetc(f)); ASSERT_FALSE(feof(f)); ASSERT_EQ(EBADF, errno); ASSERT_EQ(EBADF, ferror(f)); clearerr(f); EXPECT_EQ(5, fwrite("hello", 1, 5, f)); EXPECT_EQ(5, ftell(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen(PATH, "r"))); EXPECT_EQ(0, fwrite("hello", 1, 5, f)); EXPECT_EQ(EBADF, ferror(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen(PATH, "a+b"))); EXPECT_EQ(5, fwrite("hello", 1, 5, f)); EXPECT_NE(-1, fclose(f)); if (IsWindows()) return; ASSERT_NE(NULL, (f = fopen(PATH, "r"))); EXPECT_EQ(10, fread(buf, 1, 10, f)); EXPECT_TRUE(!memcmp(buf, "hellohello", 10)); EXPECT_NE(-1, fclose(f)); } TEST(fwrite, testSmallBuffer) { ASSERT_NE(NULL, (f = fopen(PATH, "wb"))); setbuffer(f, gc(malloc(1)), 1); EXPECT_EQ(-1, fgetc(f)); clearerr(f); EXPECT_EQ(5, fwrite("hello", 1, 5, f)); EXPECT_EQ(5, ftell(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen(PATH, "r"))); setbuffer(f, gc(malloc(1)), 1); EXPECT_EQ(0, fwrite("hello", 1, 5, f)); EXPECT_EQ(EBADF, ferror(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen(PATH, "a"))); setbuffer(f, gc(malloc(1)), 1); EXPECT_EQ(5, fwrite("hello", 1, 5, f)); EXPECT_NE(-1, fclose(f)); if (IsWindows()) return; ASSERT_NE(NULL, (f = fopen(PATH, "r"))); setbuffer(f, gc(malloc(1)), 1); EXPECT_EQ(10, fread(buf, 1, 10, f)); EXPECT_TRUE(!memcmp(buf, "hellohello", 10)); EXPECT_NE(-1, fclose(f)); } TEST(fwrite, testLineBuffer) { ASSERT_NE(NULL, (f = fopen(PATH, "wb"))); setvbuf(f, NULL, _IOLBF, 64); EXPECT_EQ(-1, fgetc(f)); clearerr(f); EXPECT_EQ(5, fwrite("heyy\n", 1, 5, f)); EXPECT_EQ(0, fread(buf, 0, 0, f)); EXPECT_FALSE(feof(f)); EXPECT_EQ(0, fread(buf, 1, 10, f)); EXPECT_EQ(EBADF, ferror(f)); EXPECT_EQ(5, ftell(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen(PATH, "r"))); setvbuf(f, NULL, _IOLBF, 64); EXPECT_EQ(0, fwrite("heyy\n", 1, 5, f)); EXPECT_EQ(EBADF, ferror(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen(PATH, "a"))); setvbuf(f, NULL, _IOLBF, 64); EXPECT_EQ(5, fwrite("heyy\n", 1, 5, f)); EXPECT_NE(-1, fclose(f)); if (IsWindows()) return; ASSERT_NE(NULL, (f = fopen(PATH, "r"))); setvbuf(f, NULL, _IOLBF, 64); EXPECT_EQ(10, fread(buf, 1, 10, f)); EXPECT_TRUE(!memcmp(buf, "heyy\nheyy\n", 10)); EXPECT_NE(-1, fclose(f)); } TEST(fwrite, testNoBuffer) { ASSERT_NE(NULL, (f = fopen(PATH, "wb"))); setvbuf(f, NULL, _IONBF, 64); EXPECT_EQ(-1, fgetc(f)); clearerr(f); EXPECT_EQ(5, fwrite("heyy\n", 1, 5, f)); EXPECT_EQ(5, ftell(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen(PATH, "r"))); setvbuf(f, NULL, _IONBF, 64); EXPECT_EQ(0, fwrite("heyy\n", 1, 5, f)); EXPECT_EQ(EBADF, ferror(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen(PATH, "a"))); setvbuf(f, NULL, _IONBF, 64); EXPECT_EQ(5, fwrite("heyy\n", 1, 5, f)); EXPECT_NE(-1, fclose(f)); if (IsWindows()) return; ASSERT_NE(NULL, (f = fopen(PATH, "r"))); setvbuf(f, NULL, _IONBF, 64); EXPECT_EQ(10, fread(buf, 1, 10, f)); EXPECT_TRUE(!memcmp(buf, "heyy\nheyy\n", 10)); EXPECT_NE(-1, fclose(f)); } void MeatyReadWriteTest(void) { size_t n; char *mem, *buf; n = 8 * 1024 * 1024; buf = gc(malloc(n)); mem = rngset(gc(malloc(n)), n, _rand64, -1); ASSERT_NE(NULL, (f = fopen(PATH, "wb"))); setbuffer(f, gc(malloc(4 * 1000 * 1000)), 4 * 1000 * 1000); EXPECT_EQ(n, fwrite(mem, 1, n, f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen(PATH, "r"))); setbuffer(f, gc(malloc(4 * 1000 * 1000)), 4 * 1000 * 1000); EXPECT_EQ(n, fread(buf, 1, n, f)); EXPECT_EQ(0, memcmp(buf, mem, n)); EXPECT_NE(-1, fclose(f)); } volatile bool gotsigint; void OnSigInt(int sig) { gotsigint = true; } TEST(fwrite, signalStorm) { if (IsWindows()) return; int pid; struct sigaction oldchld, oldint; struct sigaction sachld = {.sa_handler = SIG_IGN}; struct sigaction saint = {.sa_handler = OnSigInt}; EXPECT_NE(-1, sigaction(SIGINT, &saint, &oldint)); EXPECT_NE(-1, sigaction(SIGCHLD, &sachld, &oldchld)); ASSERT_NE(-1, (pid = fork())); if (!pid) { do { ASSERT_NE(-1, kill(getppid(), SIGINT)); usleep(25); } while (!gotsigint); _exit(0); } pause(); MeatyReadWriteTest(); EXPECT_NE(-1, kill(pid, SIGINT)); while (wait(0) == -1 && errno == EINTR) donothing; EXPECT_NE(-1, sigaction(SIGCHLD, &oldchld, NULL)); EXPECT_NE(-1, sigaction(SIGINT, &oldint, NULL)); }
6,871
187
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/fgetwc_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" TEST(fgetwc, testAscii_oneChar) { FILE *f = fmemopen(NULL, BUFSIZ, "r+"); EXPECT_EQ('A', fputc('A', f)); rewind(f); EXPECT_EQ('A', fgetc(f)); fclose(f); } TEST(fgetwc, testAscii_twoChar) { FILE *f = fmemopen(NULL, BUFSIZ, "r+"); EXPECT_EQ('A', fputc('A', f)); EXPECT_EQ('B', fputc('B', f)); rewind(f); EXPECT_EQ('A', fgetc(f)); EXPECT_EQ('B', fgetc(f)); fclose(f); } TEST(fgetwc, testUnicode_oneChar) { FILE *f = fmemopen(NULL, BUFSIZ, "r+"); EXPECT_EQ(L'𐌰', fputwc(L'𐌰', f)); rewind(f); EXPECT_EQ(L'𐌰', fgetwc(f)); fclose(f); } TEST(fgetwc, testUnicode_oneChar_writtenAsRawUtf8) { FILE *f = fmemopen(NULL, BUFSIZ, "r+"); EXPECT_EQ(0xF0, fputc(0xF0, f)); EXPECT_EQ(0x90, fputc(0x90, f)); EXPECT_EQ(0x8C, fputc(0x8C, f)); EXPECT_EQ(0xB0, fputc(0xB0, f)); rewind(f); EXPECT_EQ(L'𐌰', fgetwc(f)); fclose(f); } TEST(fgetwc, testUnicode_undecodableSequences_fallsBackToBinary) { FILE *f = fmemopen(NULL, BUFSIZ, "r+"); EXPECT_EQ(0200, fputc(0200, f)); EXPECT_EQ(0220, fputc(0220, f)); EXPECT_EQ(0xF0, fputc(0xF0, f)); EXPECT_EQ(0x90, fputc(0x90, f)); EXPECT_EQ(0x8C, fputc(0x8C, f)); EXPECT_EQ(0xB0, fputc(0xB0, f)); EXPECT_EQ(0304, fputc(0304, f)); EXPECT_EQ('a', fputc('a', f)); rewind(f); EXPECT_EQ(0200, fgetwc(f)); EXPECT_EQ(0220, fgetwc(f)); EXPECT_EQ(L'𐌰', fgetwc(f)); EXPECT_EQ(0304, fgetwc(f)); EXPECT_EQ('a', fgetwc(f)); fclose(f); }
3,370
78
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/fread_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" char testlib_enable_tmp_setup_teardown; TEST(fread, eofIsSticky) { FILE *fo, *fi; char b[10] = "hello"; ASSERT_NE(NULL, (fo = fopen("foo", "w"))); ASSERT_NE(NULL, (fi = fopen("foo", "r"))); ASSERT_EQ(0, fread(b, 1, 8, fi)); ASSERT_TRUE(feof(fi)); ASSERT_EQ(8, fwrite(b, 1, 8, fo)); ASSERT_EQ(0, fflush(fo)); ASSERT_EQ(0, fread(b, 1, 8, fi)); ASSERT_TRUE(feof(fi)); clearerr(fi); ASSERT_EQ(8, fread(b, 1, 10, fi)); ASSERT_TRUE(feof(fi)); ASSERT_EQ(0, fseek(fi, 0, SEEK_SET)); ASSERT_FALSE(feof(fi)); ASSERT_EQ(0, fclose(fi)); ASSERT_EQ(0, fclose(fo)); } TEST(fread, seekWithBuffer) { FILE *f; char b[8] = "hellosup"; char c[8] = {0}; char d[8] = {0}; ASSERT_NE(NULL, (f = fopen("foo", "w"))); ASSERT_EQ(8, fwrite(b, 1, 8, f)); ASSERT_EQ(0, fclose(f)); ASSERT_NE(NULL, (f = fopen("foo", "r"))); ASSERT_EQ(5, fread(c, 1, 5, f)); ASSERT_STREQ("hello", c); ASSERT_EQ(0, fseek(f, 1, SEEK_SET)); ASSERT_EQ(5, fread(d, 1, 5, f)); ASSERT_STREQ("ellos", d); ASSERT_EQ(0, fclose(f)); }
2,970
61
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/freopen_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" /* * This test was contributed by @ahgamut * https://github.com/jart/cosmopolitan/issues/61#issuecomment-792214575 */ char testlib_enable_tmp_setup_teardown; int writefile(const char* filename) { int stat = 0; FILE* fp = fopen(filename, "w"); stat = fputs("cosmopolitan libc\n", fp); fclose(fp); return stat; } int readfile(const char* filename) { int stat = 0; char buf1[30]; char buf2[30]; FILE *fp1, *fp2; fp1 = fopen(filename, "r"); if (!fp1) { printf("failed to read %s in r\n", filename); return 1; } buf1[0] = fgetc(fp1); buf1[1] = '\0'; fp2 = freopen(filename, "rb", fp1); if (!fp2) { printf("failed to read %s in rb\n", filename); return 1; } stat = fread(buf2, sizeof(buf2[0]), 20, fp2); ASSERT_EQ(18, stat); buf2[stat] = '\0'; fclose(fp2); ASSERT_STREQ("c", buf1); ASSERT_STREQ("cosmopolitan libc\n", buf2); return 0; } TEST(freopen, test) { writefile("file.txt"); readfile("file.txt"); }
2,876
67
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/mt19937_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/intrin/bits.h" #include "libc/log/check.h" #include "libc/macros.internal.h" #include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/grnd.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "third_party/mbedtls/ctr_drbg.h" void GetRandom(void *p, size_t n) { ssize_t rc; size_t i, m; for (i = 0; i < n; i += rc) { m = MIN(n - i, 256); rc = getrandom((char *)p + i, m, 0); if (rc == -1 && errno == EINTR) continue; if (rc <= 0) abort(); } } int GetEntropy1(void *c, unsigned char *p, size_t n) { rngset(p, n, rdseed, 0); return 0; } void ctrdrbg1(void *p, size_t n) { int rc; size_t i, m; mbedtls_ctr_drbg_context rng; mbedtls_ctr_drbg_init(&rng); DCHECK_EQ(0, mbedtls_ctr_drbg_seed(&rng, GetEntropy1, 0, "justine", 7)); for (i = 0; i < n; i += m) { m = MIN(n - i, MBEDTLS_CTR_DRBG_MAX_REQUEST); DCHECK_EQ(0, mbedtls_ctr_drbg_random(&rng, (unsigned char *)p + i, m)); } mbedtls_ctr_drbg_free(&rng); } int GetEntropy2(void *c, unsigned char *p, size_t n) { rngset(p, n, rdseed, -1); return 0; } void ctrdrbg2(void *p, size_t n) { int rc; size_t i, m; mbedtls_ctr_drbg_context rng; mbedtls_ctr_drbg_init(&rng); DCHECK_EQ(0, mbedtls_ctr_drbg_seed(&rng, GetEntropy2, 0, "justine", 7)); for (i = 0; i < n; i += m) { m = MIN(n - i, MBEDTLS_CTR_DRBG_MAX_REQUEST); DCHECK_EQ(0, mbedtls_ctr_drbg_random(&rng, (unsigned char *)p + i, m)); } mbedtls_ctr_drbg_free(&rng); } dontinline uint64_t xorshift(void) { static uint64_t s = 88172645463325252; uint64_t x = s; x ^= x << 13; x ^= x >> 7; x ^= x << 17; return (s = x); } dontinline void xorshifta(char *p, size_t n) { static uint64_t s = 88172645463325252; uint64_t x = s; while (n >= 8) { x ^= x << 13; x ^= x >> 7; x ^= x << 17; __builtin_memcpy(p, &x, 8); n -= 8; p += 8; } s = x; while (n--) { *p++ = x; x >>= 8; } } dontinline uint64_t knuth(void) { uint64_t a, b; static uint64_t x = 1; x *= 6364136223846793005; x += 1442695040888963407; a = x >> 32; x *= 6364136223846793005; x += 1442695040888963407; b = x >> 32; return a | b << 32; } dontinline void knutha(char *p, size_t n) { static uint64_t s = 1; uint32_t u; uint64_t x = s; while (n >= 4) { x *= 6364136223846793005; x += 1442695040888963407; u = x >> 32; p[0] = (0x000000FF & u) >> 000; p[1] = (0x0000FF00 & u) >> 010; p[2] = (0x00FF0000 & u) >> 020; p[3] = (0xFF000000 & u) >> 030; n -= 4; p += 4; } s = x; while (n--) { *p++ = x; x >>= 8; } } uint64_t urandom(void) { return random(); } TEST(mt19937, test) { uint64_t init[] = {0x12345ULL, 0x23456ULL, 0x34567ULL, 0x45678ULL}; uint64_t want[] = { 7266447313870364031ull, 4946485549665804864ull, 16945909448695747420ull, 16394063075524226720ull, 4873882236456199058ull, }; _Smt19937(init, ARRAYLEN(init)); for (int i = 0; i < ARRAYLEN(want); i++) { ASSERT_EQ(want[i], _mt19937()); } } BENCH(mt19937, bench8) { volatile uint64_t x; EZBENCH2("lemur64", donothing, x = lemur64()); EZBENCH2("_rand64", donothing, x = _rand64()); EZBENCH2("vigna", donothing, x = vigna()); EZBENCH2("vigna_r", donothing, vigna_r(&x)); EZBENCH2("xorshift", donothing, x = xorshift()); EZBENCH2("knuth", donothing, x = knuth()); EZBENCH2("random", donothing, x = urandom()); EZBENCH2("mt19937", donothing, x = _mt19937()); EZBENCH2("rand64char", donothing, x = _rand64()); size_t i = 0; volatile uint8_t *p = gc(malloc(3 * 2048 * 2 * 8)); EZBENCH3("rdrand", 2048, donothing, p[i++] = rdrand()); EZBENCH3("rdseed", 2048, donothing, p[i++] = rdseed()); EZBENCH3("getrandom", 2048, donothing, GetRandom(p + i++, 8)); } BENCH(mt19937, bench32k) { volatile char *p = gc(malloc(32768)); EZBENCH_N("rngset(_rand64,-1)", 32768, rngset(p, 32768, _rand64, -1)); EZBENCH_N("rngset(rdseed,512)", 32768, rngset(p, 32768, rdseed, 512)); EZBENCH_N("ctrdrbg+rdseed [blk]", 32768, ctrdrbg1(p, 32768)); EZBENCH_N("getrandom [block]", 32768, GetRandom(p, 32768)); EZBENCH_N("vigna [word]", 32768, rngset(p, 32768, vigna, 0)); EZBENCH_N("xorshift [word]", 32768, xorshifta(p, 32768)); EZBENCH_N("knuth [word]", 32768, knutha(p, 32768)); EZBENCH_N("random [word]", 32768, rngset(p, 32768, urandom, 0)); EZBENCH_N("mt19937 [word]", 32768, rngset(p, 32768, _mt19937, 0)); EZBENCH_N("_rand64 [word]", 32768, rngset(p, 32768, _rand64, 0)); EZBENCH_N("rdrand [word]", 32768, rngset(p, 32768, rdrand, 0)); EZBENCH_N("rdseed [word]", 32768, rngset(p, 32768, rdseed, 0)); } BENCH(mt19937, bench48) { volatile char *p = gc(malloc(48)); EZBENCH_N("rngset(rdrand,0)", 48, rngset(p, 48, rdrand, 0)); EZBENCH_N("rngset(rdseed,0)", 48, rngset(p, 48, rdseed, 0)); EZBENCH_N("getrandom", 48, GetRandom(p, 48)); } #if 0 TEST(mt19937, test) { int i; uint64_t init[4] = {0x12345ULL, 0x23456ULL, 0x34567ULL, 0x45678ULL}; uint64_t length = 4; mt19937_init_by_array64(init, length); printf("1000 outputs of genrand64_int64()\n"); for (i = 0; i < 1000; i++) { printf("%20llu ", mt19937_genrand64_int64()); if (i % 5 == 4) printf("\n"); } printf("\n1000 outputs of genrand64_real2()\n"); for (i = 0; i < 1000; i++) { printf("%10.8f ", mt19937_genrand64_real2()); if (i % 5 == 4) printf("\n"); } } #endif
7,383
216
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/rngset_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" #include "libc/stdio/rand.h" #include "libc/testlib/testlib.h" uint64_t counter(void) { static uint8_t t; return 0x0101010101010101ull * t++; } TEST(rngset, testZeroReseedInterval_doesntApplyPrng) { char buf[32]; EXPECT_EQ(buf, rngset(buf, sizeof(buf), counter, 0)); EXPECT_EQ(0x0000000000000000, READ64LE(buf + 0)); EXPECT_EQ(0x0101010101010101, READ64LE(buf + 8)); EXPECT_EQ(0x0202020202020202, READ64LE(buf + 16)); EXPECT_EQ(0x0303030303030303, READ64LE(buf + 24)); } uint64_t eleet(void) { return 0x31337; } TEST(rngset, testReseedIsNeg_usesInternalVignaPrng) { char buf[32]; svigna(0x31337); EXPECT_EQ(buf, rngset(buf, sizeof(buf), eleet, -1)); EXPECT_EQ(vigna(), READ64LE(buf + 0)); EXPECT_EQ(vigna(), READ64LE(buf + 8)); EXPECT_EQ(vigna(), READ64LE(buf + 16)); EXPECT_EQ(vigna(), READ64LE(buf + 24)); } TEST(rngset, testNullSeedFunction_reseedBecomesVignaSeed) { char buf[32]; svigna(123); EXPECT_EQ(buf, rngset(buf, sizeof(buf), 0, 123)); EXPECT_EQ(vigna(), READ64LE(buf + 0)); EXPECT_EQ(vigna(), READ64LE(buf + 8)); EXPECT_EQ(vigna(), READ64LE(buf + 16)); EXPECT_EQ(vigna(), READ64LE(buf + 24)); } TEST(rngset, testWeirdlyShaped_doesntCrash) { char buf[7]; rngset(buf, sizeof(buf), 0, 0); rngset(buf, sizeof(buf), vigna, 0); rngset(buf, sizeof(buf), vigna, 9); rngset(buf, sizeof(buf), vigna, 8); }
3,236
68
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/fputs_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" FILE *f; char buf[512]; char testlib_enable_tmp_setup_teardown; TEST(fputs, test) { ASSERT_NE(NULL, (f = fopen("hog", "w"))); EXPECT_EQ(5, fputs("hello", f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ(5, fread(buf, 1, 512, f)); EXPECT_TRUE(!memcmp(buf, "hello", 5)); EXPECT_TRUE(feof(f)); EXPECT_NE(-1, fclose(f)); } TEST(puts, test) { ASSERT_NE(NULL, (f = fopen("hog", "w"))); EXPECT_EQ(5, fputs("hello", f)); EXPECT_EQ('\n', fputc('\n', f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ(6, fread(buf, 1, 512, f)); EXPECT_TRUE(!memcmp(buf, "hello\n", 6)); EXPECT_TRUE(feof(f)); EXPECT_NE(-1, fclose(f)); } BENCH(fputs, bench) { char *buf = gc(malloc(kHyperionSize)); EZBENCH2("fputs", f = fmemopen(buf, kHyperionSize, "r+"), fputs(kHyperion, f)); }
2,927
59
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/joinstrlist_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" #include "libc/mem/mem.h" #include "libc/stdio/append.h" #include "libc/stdio/strlist.internal.h" #include "libc/testlib/testlib.h" struct StrList sl; void TearDown(void) { FreeStrList(&sl); } TEST(strlist, test) { int i; char *b = 0; ASSERT_NE(-1, (i = AppendStrList(&sl))); ASSERT_NE(-1, appends(&sl.p[i], "world")); ASSERT_NE(-1, (i = AppendStrList(&sl))); ASSERT_NE(-1, appends(&sl.p[i], "hello")); SortStrList(&sl); ASSERT_NE(-1, JoinStrList(&sl, &b, READ16LE(", "))); EXPECT_STREQ("hello, world", b); free(b); } TEST(strlist, testNumbers) { int i; char *b = 0; ASSERT_NE(-1, (i = AppendStrList(&sl))); ASSERT_NE(-1, appends(&sl.p[i], "2")); ASSERT_NE(-1, (i = AppendStrList(&sl))); ASSERT_NE(-1, appends(&sl.p[i], "1")); SortStrList(&sl); ASSERT_NE(-1, JoinStrList(&sl, &b, ':')); EXPECT_STREQ("1:2", b); free(b); }
2,734
56
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/getentropy_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/atomic.h" #include "libc/calls/calls.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/macros.internal.h" #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/tab.internal.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" #ifndef __aarch64__ // TODO(jart): Make this test less resource intensive. // TODO(jart): Why can EINTR happen on Windows? atomic_int done; atomic_int ready; pthread_t parent; atomic_int gotsome; void OnSig(int sig) { ++gotsome; } void *TortureWorker(void *arg) { sigset_t ss; sigfillset(&ss); ASSERT_SYS(0, 0, sigprocmask(SIG_SETMASK, &ss, 0)); ready = true; while (!done) { if (!IsWindows()) pthread_kill(parent, SIGUSR1); usleep(1); if (!IsWindows()) pthread_kill(parent, SIGUSR2); usleep(1); } return 0; } TEST(getentropy, test) { pthread_t child; double e, w = 7.7; struct sigaction sa; int i, j, k, m, n = 999; char *buf = _gc(calloc(1, n)); sa.sa_flags = 0; sa.sa_handler = OnSig; sigemptyset(&sa.sa_mask); ASSERT_SYS(0, 0, sigaction(SIGUSR1, &sa, 0)); ASSERT_SYS(0, 0, sigaction(SIGUSR2, &sa, 0)); parent = pthread_self(); ASSERT_EQ(0, pthread_create(&child, 0, TortureWorker, 0)); while (!ready) pthread_yield(); for (k = 0; k < 10; ++k) { ASSERT_SYS(0, 0, getentropy(0, 0)); for (i = 0; i < n; i += m) { m = MIN(n - i, 256); ASSERT_SYS(0, 0, getentropy(buf + i, m)); ASSERT_SYS(EFAULT, -1, getentropy(0, m)); } if ((e = MeasureEntropy(buf, n)) < w) { fprintf(stderr, "error: entropy suspect! got %g but want >=%g\n", e, w); for (i = 0; i < n;) { if (!(i % 16)) fprintf(stderr, "%6x ", i); fprintf(stderr, "%lc", kCp437[buf[i] & 255]); if (!(++i % 16)) fprintf(stderr, "\n"); } fprintf(stderr, "\n"); done = true; pthread_join(child, 0); exit(1); } } done = true; ASSERT_EQ(0, pthread_join(child, 0)); if (!IsWindows()) ASSERT_GT(gotsome, 0); } #endif /* __aarch64__ */
4,085
102
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/fputc_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/runtime/internal.h" #include "libc/stdio/lock.internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" FILE *f; char buf[512]; char testlib_enable_tmp_setup_teardown; TEST(fputc, test) { ASSERT_NE(NULL, (f = fopen("hog", "w+"))); EXPECT_EQ('h', fputc('h', f)); EXPECT_EQ(0xFF, fputc(-1, f)); EXPECT_NE(-1, fseek(f, 0, SEEK_SET)); EXPECT_EQ('h', fgetc(f)); EXPECT_EQ(0, fread(NULL, 0, 0, f)); EXPECT_FALSE(feof(f)); EXPECT_EQ(0xFF, fgetc(f)); EXPECT_EQ(-1, fgetc(f)); EXPECT_TRUE(feof(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ(2, fread(buf, 1, 512, f)); EXPECT_TRUE(!memcmp(buf, "h\377", 2)); EXPECT_TRUE(feof(f)); EXPECT_NE(-1, fclose(f)); } TEST(fgetc, testUnbuffered) { ASSERT_NE(NULL, (f = fopen("hog", "w+"))); EXPECT_NE(-1, setvbuf(f, NULL, _IONBF, 0)); EXPECT_EQ('h', fputc('h', f)); EXPECT_EQ(0xFF, fputc(-1, f)); EXPECT_NE(-1, fseek(f, 0, SEEK_SET)); EXPECT_EQ('h', fgetc(f)); EXPECT_EQ(0xFF, fgetc(f)); EXPECT_EQ(-1, fgetc(f)); EXPECT_TRUE(feof(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ(2, fread(buf, 1, 512, f)); EXPECT_TRUE(!memcmp(buf, "h\377", 2)); EXPECT_TRUE(feof(f)); EXPECT_NE(-1, fclose(f)); } BENCH(fputc, bench) { __enable_threads(); FILE *f; ASSERT_NE(NULL, (f = fopen("/dev/null", "w"))); EZBENCH2("fputc", donothing, fputc('E', f)); flockfile(f); flockfile(f); EZBENCH2("fputc_unlocked", donothing, fputc_unlocked('E', f)); funlockfile(f); funlockfile(f); fclose(f); }
3,520
80
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/dirstream_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/struct/dirent.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/sysv/consts/dt.h" #include "libc/testlib/testlib.h" #include "libc/x/xasprintf.h" #include "libc/x/xiso8601.h" STATIC_YOINK("zip_uri_support"); STATIC_YOINK("usr/share/zoneinfo/New_York"); char testlib_enable_tmp_setup_teardown; DIR *dir; struct dirent *ent; void SetUp(void) { dir = 0; ent = 0; } TEST(opendir, efault) { ASSERT_SYS(EFAULT, NULL, opendir(0)); if (!IsAsan()) return; // not possible ASSERT_SYS(EFAULT, NULL, opendir((void *)77)); } TEST(opendir, enoent) { ASSERT_SYS(ENOENT, NULL, opendir("")); ASSERT_SYS(ENOENT, NULL, opendir("o/foo")); } TEST(opendir, enotdir) { ASSERT_SYS(0, 0, close(creat("yo", 0644))); ASSERT_SYS(ENOTDIR, NULL, opendir("yo/there")); } TEST(opendir, zipTest_fake) { ASSERT_NE(NULL, (dir = opendir("/zip"))); EXPECT_NE(NULL, (ent = readdir(dir))); EXPECT_STREQ(".cosmo", ent->d_name); EXPECT_NE(NULL, (ent = readdir(dir))); EXPECT_STREQ("echo", ent->d_name); EXPECT_NE(NULL, (ent = readdir(dir))); EXPECT_STREQ("usr", ent->d_name); EXPECT_EQ(NULL, (ent = readdir(dir))); EXPECT_EQ(0, closedir(dir)); ASSERT_NE(NULL, (dir = opendir("/zip/"))); EXPECT_NE(NULL, (ent = readdir(dir))); EXPECT_STREQ(".cosmo", ent->d_name); EXPECT_NE(NULL, (ent = readdir(dir))); EXPECT_STREQ("echo", ent->d_name); EXPECT_NE(NULL, (ent = readdir(dir))); EXPECT_STREQ("usr", ent->d_name); EXPECT_EQ(NULL, (ent = readdir(dir))); EXPECT_EQ(0, closedir(dir)); ASSERT_NE(NULL, (dir = opendir("/zip/usr"))); EXPECT_NE(NULL, (ent = readdir(dir))); EXPECT_STREQ("share", ent->d_name); EXPECT_EQ(NULL, (ent = readdir(dir))); EXPECT_EQ(0, closedir(dir)); ASSERT_NE(NULL, (dir = opendir("/zip/usr/"))); EXPECT_NE(NULL, (ent = readdir(dir))); EXPECT_STREQ("share", ent->d_name); EXPECT_EQ(NULL, (ent = readdir(dir))); EXPECT_EQ(0, closedir(dir)); EXPECT_EQ(NULL, (dir = opendir("/zip/us"))); EXPECT_EQ(NULL, (dir = opendir("/zip/us/"))); } TEST(dirstream, testDots) { int hasdot = 0; int hasdotdot = 0; ASSERT_SYS(0, 0, close(creat("foo", 0644))); ASSERT_NE(NULL, (dir = opendir("."))); while ((ent = readdir(dir))) { if (!strcmp(ent->d_name, ".")) { ++hasdot; EXPECT_EQ(DT_DIR, ent->d_type); } if (!strcmp(ent->d_name, "..")) { ++hasdotdot; EXPECT_EQ(DT_DIR, ent->d_type); } } EXPECT_EQ(1, hasdot); EXPECT_EQ(1, hasdotdot); EXPECT_SYS(0, 0, closedir(dir)); } TEST(dirstream, test) { bool hasfoo = false; bool hasbar = false; char *dpath, *file1, *file2; dpath = _gc(xasprintf("%s.%d", "dirstream", rand())); file1 = _gc(xasprintf("%s/%s", dpath, "foo")); file2 = _gc(xasprintf("%s/%s", dpath, "bar")); EXPECT_NE(-1, mkdir(dpath, 0755)); EXPECT_NE(-1, touch(file1, 0644)); EXPECT_NE(-1, touch(file2, 0644)); EXPECT_TRUE(NULL != (dir = opendir(dpath))); while ((ent = readdir(dir))) { if (!strcmp(ent->d_name, "foo")) { EXPECT_EQ(DT_REG, ent->d_type); hasfoo = true; } if (!strcmp(ent->d_name, "bar")) { EXPECT_EQ(DT_REG, ent->d_type); hasbar = true; } } EXPECT_TRUE(hasfoo); EXPECT_TRUE(hasbar); EXPECT_NE(-1, closedir(dir)); EXPECT_NE(-1, unlink(file2)); EXPECT_NE(-1, unlink(file1)); EXPECT_NE(-1, rmdir(dpath)); } TEST(dirstream, zipTest) { bool foundNewYork = false; const char *path = "/zip/usr/share/zoneinfo/"; ASSERT_NE(0, _gc(xiso8601ts(NULL))); ASSERT_NE(NULL, (dir = opendir(path))); while ((ent = readdir(dir))) { foundNewYork |= !strcmp(ent->d_name, "New_York"); } closedir(dir); EXPECT_TRUE(foundNewYork); } TEST(rewinddir, test) { bool hasfoo = false; bool hasbar = false; char *dpath, *file1, *file2; dpath = _gc(xasprintf("%s.%d", "dirstream", rand())); file1 = _gc(xasprintf("%s/%s", dpath, "foo")); file2 = _gc(xasprintf("%s/%s", dpath, "bar")); EXPECT_NE(-1, mkdir(dpath, 0755)); EXPECT_NE(-1, touch(file1, 0644)); EXPECT_NE(-1, touch(file2, 0644)); EXPECT_TRUE(NULL != (dir = opendir(dpath))); readdir(dir); readdir(dir); readdir(dir); rewinddir(dir); while ((ent = readdir(dir))) { if (strcmp(ent->d_name, "foo")) hasfoo = true; if (strcmp(ent->d_name, "bar")) hasbar = true; } EXPECT_TRUE(hasfoo); EXPECT_TRUE(hasbar); EXPECT_NE(-1, closedir(dir)); EXPECT_NE(-1, unlink(file2)); EXPECT_NE(-1, unlink(file1)); EXPECT_NE(-1, rmdir(dpath)); } TEST(dirstream, zipTest_notDir) { ASSERT_EQ(NULL, opendir("/zip/usr/share/zoneinfo/New_York")); ASSERT_EQ(ENOTDIR, errno); }
6,574
186
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/mkostempsm_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" #include "libc/errno.h" #include "libc/runtime/runtime.h" #include "libc/stdio/internal.h" #include "libc/stdio/temp.h" #include "libc/sysv/consts/o.h" #include "libc/testlib/testlib.h" #define Mode() \ ({ \ va_list va; \ unsigned Mode; \ va_start(va, flags); \ Mode = va_arg(va, unsigned); \ va_end(va); \ Mode; \ }) static int MockOpen1(const char *file, int flags, ...) { static bool once; ASSERT_FALSE(once); once = true; EXPECT_STREQ("/tmp/mkostemps.ctre5m", file); EXPECT_EQ(O_RDWR | O_CREAT | O_EXCL, flags); EXPECT_EQ(0600, Mode()); return 123; } TEST(mkostempsm, test1) { uint64_t rando = 1; char path[PATH_MAX] = "/tmp/mkostemps.XXXXXX"; EXPECT_EQ(123L, mkostempsmi(path, 0, 0, &rando, 0600, MockOpen1)); EXPECT_STREQ("/tmp/mkostemps.ctre5m", path); } static int MockOpen2(const char *file, int flags, ...) { static int state; switch (state) { case 0: state = 1; EXPECT_STREQ("/tmp/mkostemps.ctre5m", file); EXPECT_EQ((unsigned)(O_RDWR | O_CREAT | O_EXCL), flags); EXPECT_EQ(0600, Mode()); errno = EEXIST; return -1; case 1: state = 1; EXPECT_STREQ("/tmp/mkostemps.jl1h61", file); EXPECT_EQ((unsigned)(O_RDWR | O_CREAT | O_EXCL), flags); EXPECT_EQ(0600, Mode()); return 123; default: abort(); } } TEST(mkostempsm, test2) { uint64_t rando = 1; char path[PATH_MAX] = "/tmp/mkostemps.XXXXXX"; EXPECT_EQ(123, mkostempsmi(path, 0, 0, &rando, 0600, MockOpen2)); EXPECT_STREQ("/tmp/mkostemps.jl1h61", path); }
3,557
81
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/ftell_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" FILE *f; char buf[512]; char testlib_enable_tmp_setup_teardown; TEST(ftell, test) { ASSERT_NE(NULL, (f = fopen("hog", "w"))); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(5, fputs("hello", f)); EXPECT_EQ(5, ftell(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(1, fread(buf, 1, 1, f)); EXPECT_EQ(1, ftell(f)); EXPECT_EQ('h', buf[0]); EXPECT_EQ(2, fread(buf, 1, 2, f)); EXPECT_EQ(3, ftell(f)); EXPECT_EQ('e', buf[0]); EXPECT_EQ('l', buf[1]); EXPECT_FALSE(feof(f)); EXPECT_EQ(2, fread(buf, 1, 512, f)); EXPECT_EQ(5, ftell(f)); EXPECT_TRUE(feof(f)); EXPECT_EQ('l', buf[0]); EXPECT_EQ('o', buf[1]); EXPECT_NE(-1, fclose(f)); } TEST(ftell, testSmallBuffer) { ASSERT_NE(NULL, (f = fopen("hog", "w"))); EXPECT_NE(-1, setvbuf(f, gc(xmalloc(1)), _IOFBF, 1)); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(5, fputs("hello", f)); EXPECT_EQ(5, ftell(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_NE(-1, setvbuf(f, gc(xmalloc(1)), _IOFBF, 1)); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(1, fread(buf, 1, 1, f)); EXPECT_EQ(1, ftell(f)); EXPECT_EQ('h', buf[0]); EXPECT_EQ(2, fread(buf, 1, 2, f)); EXPECT_FALSE(feof(f)); EXPECT_EQ(3, ftell(f)); EXPECT_EQ('e', buf[0]); EXPECT_EQ('l', buf[1]); EXPECT_FALSE(feof(f)); EXPECT_EQ(2, fread(buf, 1, 512, f)); EXPECT_EQ(5, ftell(f)); EXPECT_TRUE(feof(f)); EXPECT_EQ('l', buf[0]); EXPECT_EQ('o', buf[1]); EXPECT_NE(-1, fclose(f)); } TEST(ftell, testNoBuffer) { ASSERT_NE(NULL, (f = fopen("hog", "w"))); EXPECT_NE(-1, setvbuf(f, gc(xmalloc(0)), _IONBF, 0)); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(5, fputs("hello", f)); EXPECT_EQ(5, ftell(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_NE(-1, setvbuf(f, gc(xmalloc(0)), _IONBF, 0)); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(1, fread(buf, 1, 1, f)); EXPECT_EQ(1, ftell(f)); EXPECT_EQ('h', buf[0]); EXPECT_EQ(2, fread(buf, 1, 2, f)); EXPECT_FALSE(feof(f)); EXPECT_EQ(3, ftell(f)); EXPECT_EQ('e', buf[0]); EXPECT_EQ('l', buf[1]); EXPECT_FALSE(feof(f)); EXPECT_EQ(2, fread(buf, 1, 512, f)); EXPECT_EQ(5, ftell(f)); EXPECT_TRUE(feof(f)); EXPECT_EQ('l', buf[0]); EXPECT_EQ('o', buf[1]); EXPECT_NE(-1, fclose(f)); } TEST(fseek, test) { ASSERT_NE(NULL, (f = fopen("hog", "w"))); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(5, fputs("hello", f)); EXPECT_EQ(5, ftell(f)); EXPECT_EQ(0, fseek(f, -3, SEEK_CUR)); EXPECT_EQ(2, ftell(f)); EXPECT_EQ(1, fputs("L", f)); EXPECT_EQ(3, ftell(f)); EXPECT_EQ(0, fseek(f, -1, SEEK_END)); EXPECT_EQ(4, ftell(f)); EXPECT_EQ(1, fputs("O", f)); EXPECT_EQ(5, ftell(f)); EXPECT_EQ(0, fseek(f, 0, SEEK_SET)); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(1, fputs("H", f)); EXPECT_EQ(1, ftell(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ(5, fread(buf, 1, 512, f)); EXPECT_BINEQ(u"HeLlO", buf); EXPECT_NE(-1, fclose(f)); } TEST(fseek, testMemory) { ASSERT_NE(NULL, (f = fmemopen(gc(strdup("hello")), 5, "r+"))); EXPECT_EQ(0, fseek(f, 0, SEEK_END)); EXPECT_EQ(5, ftell(f)); EXPECT_EQ(0, fseek(f, -3, SEEK_CUR)); EXPECT_EQ(2, ftell(f)); EXPECT_EQ(1, fputs("L", f)); EXPECT_EQ(3, ftell(f)); EXPECT_EQ(0, fseek(f, -1, SEEK_END)); EXPECT_EQ(4, ftell(f)); EXPECT_EQ(1, fputs("O", f)); EXPECT_EQ(5, ftell(f)); EXPECT_EQ(0, fseek(f, 0, SEEK_SET)); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(1, fputs("H", f)); EXPECT_EQ(1, ftell(f)); rewind(f); EXPECT_EQ(5, fread(buf, 1, 512, f)); EXPECT_BINEQ(u"HeLlO", buf); EXPECT_NE(-1, fclose(f)); } TEST(fseek, testSmallBuffer) { ASSERT_NE(NULL, (f = fopen("hog", "w"))); EXPECT_NE(-1, setvbuf(f, gc(xmalloc(1)), _IOFBF, 1)); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(5, fputs("hello", f)); EXPECT_EQ(5, ftell(f)); EXPECT_EQ(0, fseek(f, -3, SEEK_CUR)); EXPECT_EQ(2, ftell(f)); EXPECT_EQ(1, fputs("L", f)); EXPECT_EQ(3, ftell(f)); EXPECT_EQ(0, fseek(f, -1, SEEK_END)); EXPECT_EQ(4, ftell(f)); EXPECT_EQ(1, fputs("O", f)); EXPECT_EQ(5, ftell(f)); EXPECT_EQ(0, fseek(f, 0, SEEK_SET)); EXPECT_EQ(0, ftell(f)); EXPECT_EQ(1, fputs("H", f)); EXPECT_EQ(1, ftell(f)); EXPECT_NE(-1, fclose(f)); ASSERT_NE(NULL, (f = fopen("hog", "r"))); EXPECT_EQ(5, fread(buf, 1, 512, f)); EXPECT_BINEQ(u"HeLlO", buf); EXPECT_NE(-1, fclose(f)); }
6,409
178
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/rand_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" TEST(rand002, alwaysReturnsPositiveNumbers) { for (unsigned i = 0; i < 100; ++i) { ASSERT_GT(rand(), 0); } } TEST(rand003, srandSmokeTest) { srand(1); ASSERT_EQ(908834774, rand()); srand(1); ASSERT_EQ(908834774, rand()); srand(7); ASSERT_EQ(1059165278, rand()); } TEST(rand005, rand64SmokeTest) { ASSERT_TRUE(_rand64() != _rand64() || _rand64() != _rand64()); } TEST(_rand64, test) { char *p; size_t i; uint64_t x; p = memcpy(malloc(kHyperionSize), kHyperion, kHyperionSize); for (i = 0; i < kHyperionSize / 8; ++i) { x = _rand64(); WRITE64LE(p + i * 8, x); } free(p); }
2,635
56
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/system_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/mem/copyfd.internal.h" #include "libc/mem/gc.h" #include "libc/paths.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" #ifdef __x86_64__ STATIC_YOINK("glob"); char testlib_enable_tmp_setup_teardown; void SetUp(void) { if (IsWindows()) { fprintf(stderr, "TODO(jart): Why does system_test have issues on Windows when " "running as a subprocess of something like runitd.com?\n"); exit(0); } } TEST(system, haveShell) { ASSERT_TRUE(system(0)); } TEST(system, echo) { ASSERT_EQ(0, system("echo hello >\"hello there.txt\"")); EXPECT_STREQ("hello\n", _gc(xslurp("hello there.txt", 0))); } TEST(system, exit) { ASSERT_EQ(123, WEXITSTATUS(system("exit 123"))); } TEST(system, testStdoutRedirect) { testlib_extract("/zip/echo.com", "echo.com", 0755); ASSERT_EQ(0, system("./echo.com hello >hello.txt")); EXPECT_STREQ("hello\n", _gc(xslurp("hello.txt", 0))); } TEST(system, testStdoutRedirect_withSpacesInFilename) { testlib_extract("/zip/echo.com", "echo.com", 0755); ASSERT_EQ(0, system("./echo.com hello >\"hello there.txt\"")); EXPECT_STREQ("hello\n", _gc(xslurp("hello there.txt", 0))); } TEST(system, testStderrRedirect_toStdout) { int pipefd[2]; int stdoutBack = dup(1); ASSERT_NE(-1, stdoutBack); ASSERT_EQ(0, pipe(pipefd)); ASSERT_NE(-1, dup2(pipefd[1], 1)); int stderrBack = dup(2); ASSERT_NE(-1, stderrBack); char buf[5] = {0}; ASSERT_NE(-1, dup2(1, 2)); bool success = false; if (WEXITSTATUS(system("echo aaa 2>&1")) == 0) { success = read(pipefd[0], buf, sizeof(buf) - 1) == (sizeof(buf) - 1); } ASSERT_NE(-1, dup2(stderrBack, 2)); ASSERT_EQ(true, success); ASSERT_STREQ("aaa\n", buf); buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0; testlib_extract("/zip/echo.com", "echo.com", 0755); ASSERT_NE(-1, dup2(1, 2)); success = false; if (WEXITSTATUS(system("./echo.com aaa 2>&1")) == 0) { success = read(pipefd[0], buf, sizeof(buf) - 1) == (sizeof(buf) - 1); } ASSERT_NE(-1, dup2(stderrBack, 2)); ASSERT_EQ(true, success); ASSERT_STREQ("aaa\n", buf); ASSERT_NE(-1, dup2(stdoutBack, 1)); ASSERT_EQ(0, close(pipefd[1])); ASSERT_EQ(0, close(pipefd[0])); } BENCH(system, bench) { testlib_extract("/zip/echo.com", "echo.com", 0755); EZBENCH2("system cmd", donothing, system("./echo.com hi >/dev/null")); EZBENCH2("cocmd echo", donothing, system("echo hi >/dev/null")); EZBENCH2("cocmd exit", donothing, system("exit")); } TEST(system, and) { ASSERT_EQ(1, WEXITSTATUS(system("false && false"))); ASSERT_EQ(1, WEXITSTATUS(system("true&& false"))); ASSERT_EQ(1, WEXITSTATUS(system("false &&true"))); ASSERT_EQ(0, WEXITSTATUS(system("true&&true"))); } TEST(system, or) { ASSERT_EQ(1, WEXITSTATUS(system("false || false"))); ASSERT_EQ(0, WEXITSTATUS(system("true|| false"))); ASSERT_EQ(0, WEXITSTATUS(system("false ||true"))); ASSERT_EQ(0, WEXITSTATUS(system("true||true"))); } TEST(system, async1) { ASSERT_EQ(123, WEXITSTATUS(system("exit 123 & " "wait $!"))); } TEST(system, async4) { ASSERT_EQ(0, WEXITSTATUS(system("echo a >a & " "echo b >b & " "echo c >c & " "echo d >d & " "wait"))); ASSERT_TRUE(fileexists("a")); ASSERT_TRUE(fileexists("b")); ASSERT_TRUE(fileexists("c")); ASSERT_TRUE(fileexists("d")); } TEST(system, equals) { setenv("var", "wand", true); ASSERT_EQ(0, WEXITSTATUS(system("test a = a"))); ASSERT_EQ(1, WEXITSTATUS(system("test a = b"))); ASSERT_EQ(0, WEXITSTATUS(system("test x$var = xwand"))); ASSERT_EQ(0, WEXITSTATUS(system("[ a = a ]"))); ASSERT_EQ(1, WEXITSTATUS(system("[ a = b ]"))); } TEST(system, notequals) { ASSERT_EQ(1, WEXITSTATUS(system("test a != a"))); ASSERT_EQ(0, WEXITSTATUS(system("test a != b"))); } TEST(system, usleep) { ASSERT_EQ(0, WEXITSTATUS(system("usleep & kill $!"))); } TEST(system, kill) { int ws = system("kill -TERM $$; usleep"); if (!IsWindows()) ASSERT_EQ(SIGTERM, WTERMSIG(ws)); } TEST(system, exitStatusPreservedAfterSemiColon) { testlib_extract("/zip/false.com", "false.com", 0755); ASSERT_EQ(1, WEXITSTATUS(system("false;"))); ASSERT_EQ(1, WEXITSTATUS(system("false; "))); ASSERT_EQ(1, WEXITSTATUS(system("./false.com;"))); ASSERT_EQ(1, WEXITSTATUS(system("./false.com;"))); int pipefd[2]; int stdoutBack = dup(1); ASSERT_NE(-1, stdoutBack); ASSERT_EQ(0, pipe(pipefd)); ASSERT_NE(-1, dup2(pipefd[1], 1)); ASSERT_EQ(0, WEXITSTATUS(system("false; echo $?"))); char buf[3] = {0}; ASSERT_EQ(2, read(pipefd[0], buf, 2)); ASSERT_STREQ("1\n", buf); ASSERT_EQ(0, WEXITSTATUS(system("./false.com; echo $?"))); buf[0] = 0; buf[1] = 0; ASSERT_EQ(2, read(pipefd[0], buf, 2)); ASSERT_STREQ("1\n", buf); ASSERT_NE(-1, dup2(stdoutBack, 1)); ASSERT_EQ(0, close(pipefd[1])); ASSERT_EQ(0, close(pipefd[0])); } TEST(system, allowsLoneCloseCurlyBrace) { int pipefd[2]; int stdoutBack = dup(1); ASSERT_NE(-1, stdoutBack); ASSERT_EQ(0, pipe(pipefd)); ASSERT_NE(-1, dup2(pipefd[1], 1)); char buf[6] = {0}; ASSERT_EQ(0, WEXITSTATUS(system("echo \"aaa\"}"))); ASSERT_EQ(sizeof(buf) - 1, read(pipefd[0], buf, sizeof(buf) - 1)); ASSERT_STREQ("aaa}\n", buf); buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0; buf[4] = 0; testlib_extract("/zip/echo.com", "echo.com", 0755); ASSERT_EQ(0, WEXITSTATUS(system("./echo.com \"aaa\"}"))); ASSERT_EQ(sizeof(buf) - 1, read(pipefd[0], buf, sizeof(buf) - 1)); ASSERT_STREQ("aaa}\n", buf); ASSERT_NE(-1, dup2(stdoutBack, 1)); ASSERT_EQ(0, close(pipefd[1])); ASSERT_EQ(0, close(pipefd[0])); } TEST(system, glob) { testlib_extract("/zip/echo.com", "echo.com", 0755); ASSERT_EQ(0, WEXITSTATUS(system("./ec*.com aaa"))); ASSERT_EQ(0, WEXITSTATUS(system("./ec?o.com aaa"))); } #endif /* __x86_64__ */
8,004
227
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/tmpfile_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/struct/dirent.h" #include "libc/calls/struct/stat.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" #include "libc/mem/gc.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/stdio/temp.h" #include "libc/str/str.h" #include "libc/sysv/consts/at.h" #include "libc/testlib/testlib.h" #include "libc/x/xasprintf.h" char testlib_enable_tmp_setup_teardown; char oldtmpdir[PATH_MAX]; bool IsDirectoryEmpty(const char *path) { DIR *d; bool res = true; struct dirent *e; ASSERT_NE(NULL, (d = opendir(path))); while ((e = readdir(d))) { if (!strcmp(e->d_name, ".")) continue; if (!strcmp(e->d_name, "..")) continue; res = false; } closedir(d); return res; } void SetUp(void) { strcpy(oldtmpdir, kTmpPath); strcpy(kTmpPath, "."); } void TearDown(void) { strcpy(kTmpPath, oldtmpdir); } TEST(tmpfile, test) { FILE *f; struct stat st; EXPECT_TRUE(IsDirectoryEmpty(kTmpPath)); f = tmpfile(); if (IsWindows()) { EXPECT_FALSE(IsDirectoryEmpty(kTmpPath)); } else { EXPECT_TRUE(IsDirectoryEmpty(kTmpPath)); } EXPECT_SYS(0, 0, fstat(fileno(f), &st)); EXPECT_NE(010600, st.st_mode); EXPECT_NE(-1, fputc('t', f)); EXPECT_NE(-1, fflush(f)); rewind(f); EXPECT_EQ('t', fgetc(f)); EXPECT_EQ(0, fclose(f)); EXPECT_TRUE(IsDirectoryEmpty(kTmpPath)); } #ifndef __aarch64__ // TODO(jart): Find way to detect qemu-aarch64 TEST(tmpfile, renameToRealFile) { if (!IsLinux() || !__is_linux_2_6_23()) return; FILE *f; f = tmpfile(); ASSERT_EQ(2, fputs("hi", f)); ASSERT_SYS(0, 0, linkat(AT_FDCWD, _gc(xasprintf("/proc/self/fd/%d", fileno(f))), AT_FDCWD, "real", AT_SYMLINK_FOLLOW)); ASSERT_EQ(0, fclose(f)); ASSERT_NE(NULL, (f = fopen("real", "r"))); ASSERT_EQ('h', fgetc(f)); ASSERT_EQ('i', fgetc(f)); ASSERT_EQ(0, fclose(f)); } #endif
3,777
96
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/test.mk
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ #───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ PKGS += TEST_LIBC_STDIO TEST_LIBC_STDIO_SRCS := $(wildcard test/libc/stdio/*.c) TEST_LIBC_STDIO_SRCS_TEST = $(filter %_test.c,$(TEST_LIBC_STDIO_SRCS)) TEST_LIBC_STDIO_OBJS = \ $(TEST_LIBC_STDIO_SRCS:%.c=o/$(MODE)/%.o) TEST_LIBC_STDIO_COMS = \ $(TEST_LIBC_STDIO_SRCS:%.c=o/$(MODE)/%.com) TEST_LIBC_STDIO_BINS = \ $(TEST_LIBC_STDIO_COMS) \ $(TEST_LIBC_STDIO_COMS:%=%.dbg) TEST_LIBC_STDIO_TESTS = \ $(TEST_LIBC_STDIO_SRCS_TEST:%.c=o/$(MODE)/%.com.ok) TEST_LIBC_STDIO_CHECKS = \ $(TEST_LIBC_STDIO_SRCS_TEST:%.c=o/$(MODE)/%.com.runs) TEST_LIBC_STDIO_DIRECTDEPS = \ LIBC_CALLS \ LIBC_FMT \ LIBC_INTRIN \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ LIBC_STDIO \ LIBC_STR \ LIBC_STUBS \ LIBC_SYSV \ LIBC_TINYMATH \ LIBC_TESTLIB \ LIBC_THREAD \ LIBC_TIME \ LIBC_LOG \ LIBC_X \ LIBC_ZIPOS \ THIRD_PARTY_GDTOA \ THIRD_PARTY_MBEDTLS \ THIRD_PARTY_MUSL \ THIRD_PARTY_ZLIB \ THIRD_PARTY_ZLIB_GZ TEST_LIBC_STDIO_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_STDIO_DIRECTDEPS),$($(x)))) o/$(MODE)/test/libc/stdio/stdio.pkg: \ $(TEST_LIBC_STDIO_OBJS) \ $(foreach x,$(TEST_LIBC_STDIO_DIRECTDEPS),$($(x)_A).pkg) o/$(MODE)/test/libc/stdio/%.com.dbg: \ $(TEST_LIBC_STDIO_DEPS) \ o/$(MODE)/test/libc/stdio/%.o \ o/$(MODE)/test/libc/stdio/stdio.pkg \ o/$(MODE)/tool/build/echo.zip.o \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) o/$(MODE)/test/libc/stdio/system_test.com.dbg: \ $(TEST_LIBC_STDIO_DEPS) \ o/$(MODE)/test/libc/stdio/system_test.o \ o/$(MODE)/test/libc/stdio/stdio.pkg \ o/$(MODE)/tool/build/echo.com.zip.o \ o/$(MODE)/tool/build/cocmd.com.zip.o \ o/$(MODE)/tool/build/false.com.zip.o \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) o/$(MODE)/test/libc/stdio/popen_test.com.dbg: \ $(TEST_LIBC_STDIO_DEPS) \ o/$(MODE)/test/libc/stdio/popen_test.o \ o/$(MODE)/test/libc/stdio/stdio.pkg \ o/$(MODE)/tool/build/echo.com.zip.o \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) o/$(MODE)/test/libc/stdio/posix_spawn_test.com.dbg: \ $(TEST_LIBC_STDIO_DEPS) \ o/$(MODE)/test/libc/stdio/posix_spawn_test.o \ o/$(MODE)/test/libc/stdio/stdio.pkg \ o/$(MODE)/tool/build/echo.com.zip.o \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) o/$(MODE)/test/libc/stdio/wut_test.com.dbg: \ $(TEST_LIBC_STDIO_DEPS) \ o/$(MODE)/test/libc/stdio/wut_test.o \ o/$(MODE)/test/libc/stdio/stdio.pkg \ o/$(MODE)/tool/build/echo.com.zip.o \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) $(TEST_LIBC_STDIO_OBJS): private \ DEFAULT_CCFLAGS += \ -fno-builtin .PHONY: o/$(MODE)/test/libc/stdio o/$(MODE)/test/libc/stdio: \ $(TEST_LIBC_STDIO_BINS) \ $(TEST_LIBC_STDIO_CHECKS)
3,186
116
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/popen_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/struct/sigaction.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" #include "libc/intrin/kprintf.h" #include "libc/limits.h" #include "libc/log/log.h" #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/lock.internal.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/f.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" #ifdef __x86_64__ FILE *f; char buf[32]; char testlib_enable_tmp_setup_teardown; void CheckForFdLeaks(void) { int rc, i, l = 0, e = errno; for (i = 3; i < 16; ++i) { rc = fcntl(i, F_GETFL); if (rc == -1) { ASSERT_EQ(EBADF, errno); errno = e; } else { kprintf("file descriptor %d leaked!\n", i); ++l; } } if (l) { __die(); } } TEST(popen, command) { char foo[6]; testlib_extract("/zip/echo.com", "echo.com", 0755); ASSERT_NE(NULL, (f = popen("./echo.com hello", "r"))); ASSERT_NE(NULL, fgets(foo, sizeof(foo), f)); ASSERT_STREQ("hello", foo); ASSERT_EQ(0, pclose(f)); CheckForFdLeaks(); } TEST(popen, semicolon) { ASSERT_NE(NULL, (f = popen("echo hello;echo there", "r"))); ASSERT_STREQ("hello\n", fgets(buf, sizeof(buf), f)); ASSERT_STREQ("there\n", fgets(buf, sizeof(buf), f)); ASSERT_EQ(0, pclose(f)); CheckForFdLeaks(); } TEST(popen, singleQuotes) { setenv("there", "a b c", true); ASSERT_NE(NULL, (f = popen("echo -l 'hello $there' yo", "r"))); ASSERT_STREQ("hello $there\n", fgets(buf, sizeof(buf), f)); ASSERT_STREQ("yo\n", fgets(buf, sizeof(buf), f)); ASSERT_EQ(0, pclose(f)); CheckForFdLeaks(); } TEST(popen, doubleQuotes) { setenv("hello", "a b c", true); ASSERT_NE(NULL, (f = popen("echo -l \"$hello there\"", "r"))); ASSERT_STREQ("a b c there\n", fgets(buf, sizeof(buf), f)); ASSERT_EQ(0, pclose(f)); CheckForFdLeaks(); } TEST(popen, quoteless) { setenv("there", "a b c", true); ASSERT_NE(NULL, (f = popen("echo -l hello a$there yo", "r"))); ASSERT_STREQ("hello\n", fgets(buf, sizeof(buf), f)); ASSERT_STREQ("aa b c\n", fgets(buf, sizeof(buf), f)); // mixed feelings ASSERT_STREQ("yo\n", fgets(buf, sizeof(buf), f)); ASSERT_EQ(0, pclose(f)); CheckForFdLeaks(); } TEST(popen, pipe) { setenv("there", "a b c", true); ASSERT_NE(NULL, (f = popen("echo hello | toupper", "r"))); ASSERT_STREQ("HELLO\n", fgets(buf, sizeof(buf), f)); ASSERT_EQ(0, pclose(f)); CheckForFdLeaks(); } sig_atomic_t gotsig; void OnSig(int sig) { gotsig = 1; } TEST(popen, complicated) { if (IsWindows()) return; // windows treats sigusr1 as terminate char cmd[64]; signal(SIGUSR1, OnSig); sprintf(cmd, "read a ; test \"x$a\" = xhello && kill -USR1 %d", getpid()); ASSERT_NE(NULL, (f = popen(cmd, "w"))); ASSERT_GE(fputs("hello", f), 0); ASSERT_EQ(0, pclose(f)); ASSERT_EQ(1, gotsig); signal(SIGUSR1, SIG_DFL); CheckForFdLeaks(); } void *Worker(void *arg) { FILE *f; char buf[32]; char *arg1, *arg2, *cmd; for (int i = 0; i < 8; ++i) { cmd = malloc(64); arg1 = malloc(13); arg2 = malloc(13); FormatInt32(arg1, _rand64()); FormatInt32(arg2, _rand64()); sprintf(cmd, "echo %s; ./echo.com %s", arg1, arg2); strcat(arg1, "\n"); strcat(arg2, "\n"); ASSERT_NE(NULL, (f = popen(cmd, "r"))); ASSERT_STREQ(arg1, fgets(buf, sizeof(buf), f)); ASSERT_STREQ(arg2, fgets(buf, sizeof(buf), f)); ASSERT_EQ(0, pclose(f)); free(arg2); free(arg1); free(cmd); } return 0; } TEST(popen, torture) { int i, n = 4; pthread_t *t = _gc(malloc(sizeof(pthread_t) * n)); testlib_extract("/zip/echo.com", "echo.com", 0755); for (i = 0; i < n; ++i) ASSERT_EQ(0, pthread_create(t + i, 0, Worker, 0)); for (i = 0; i < n; ++i) ASSERT_EQ(0, pthread_join(t[i], 0)); CheckForFdLeaks(); } #endif /* __x86_64__ */
5,831
168
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/getdelim_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/intrin/bits.h" #include "libc/log/libfatal.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/symbols.internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" char testlib_enable_tmp_setup_teardown; TEST(getline, testEmpty) { FILE *f = fmemopen("", 0, "r+"); char *line = NULL; size_t linesize = 0; EXPECT_EQ(-1, getline(&line, &linesize, f)); EXPECT_TRUE(feof(f)); EXPECT_FALSE(ferror(f)); EXPECT_EQ(0, fclose(f)); free(line); } TEST(getline, testOneWithoutLineFeed) { FILE *f = fmemopen("hello", 5, "r+"); char *line = NULL; size_t linesize = 0; ASSERT_EQ(5, getline(&line, &linesize, f)); EXPECT_STREQ("hello", line); EXPECT_TRUE(feof(f)); EXPECT_FALSE(ferror(f)); ASSERT_EQ(-1, getline(&line, &linesize, f)); EXPECT_EQ(0, fclose(f)); free(line); } TEST(getline, testTwoLines) { const char *s = "hello\nthere\n"; FILE *f = fmemopen(s, strlen(s), "r+"); char *line = NULL; size_t linesize = 0; ASSERT_EQ(6, getline(&line, &linesize, f)); EXPECT_STREQ("hello\n", line); EXPECT_FALSE(feof(f) | ferror(f)); ASSERT_EQ(6, getline(&line, &linesize, f)); EXPECT_STREQ("there\n", line); ASSERT_EQ(-1, getline(&line, &linesize, f)); EXPECT_STREQ("", line); EXPECT_EQ(0, fclose(f)); free(line); } TEST(getline, testBinaryLine_countExcludesOnlyTheBonusNul) { const char s[] = "he\0\3o\n"; FILE *f = fmemopen(s, sizeof(s), "r+"); char *line = NULL; size_t linesize = 0; ASSERT_EQ(6, getline(&line, &linesize, f)); EXPECT_BINEQ(u"he ♥o◙ ", line); fclose(f); free(line); } void WriteHyperionFile(void) { FILE *f; ASSERT_NE(NULL, (f = fopen("hyperion.txt", "w"))); EXPECT_EQ(1, fwrite(kHyperion, kHyperionSize, 1, f)); EXPECT_NE(-1, fclose(f)); } void ReadHyperionLines(void) { FILE *f; ssize_t rc; char *data = NULL; size_t size = 0; char *line = NULL; size_t linesize = 0; ASSERT_NE(NULL, (f = fopen("hyperion.txt", "r"))); int i = 0; for (;;) { rc = getline(&line, &linesize, f); if (rc == -1) break; data = xrealloc(data, size + rc); memcpy(data + size, line, rc); size += rc; } EXPECT_TRUE(feof(f)); ASSERT_EQ(kHyperionSize, size); EXPECT_EQ(0, memcmp(kHyperion, data, size)); EXPECT_NE(-1, fclose(f)); free(line); free(data); } TEST(getline, lotsOfLines_roundTrips) { WriteHyperionFile(); ReadHyperionLines(); } BENCH(getline, bench) { WriteHyperionFile(); EZBENCH2("getline", donothing, ReadHyperionLines()); }
4,488
124
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/getrandom_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "ape/sections.internal.h" #include "libc/atomic.h" #include "libc/calls/calls.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" #include "libc/errno.h" #include "libc/intrin/bits.h" #include "libc/log/check.h" #include "libc/macros.internal.h" #include "libc/math.h" #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/x86feature.h" #include "libc/runtime/runtime.h" #include "libc/stdio/lcg.internal.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/str/tab.internal.h" #include "libc/sysv/consts/grnd.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" #ifndef __aarch64__ // TODO(jart): Make this test less CPU intensive. atomic_int done; atomic_int ready; pthread_t parent; atomic_int gotsome; void OnSig(int sig) { ++gotsome; } void *TortureWorker(void *arg) { sigset_t ss; sigfillset(&ss); ASSERT_SYS(0, 0, sigprocmask(SIG_SETMASK, &ss, 0)); ready = true; while (!done) { if (!IsWindows()) pthread_kill(parent, SIGUSR1); usleep(1); if (!IsWindows()) pthread_kill(parent, SIGUSR2); usleep(1); } return 0; } TEST(getrandom, test) { double e, w = 7.7; int i, j, n = 999; char *buf = _gc(calloc(1, n)); ASSERT_SYS(0, 0, getrandom(0, 0, 0)); ASSERT_SYS(0, n, getrandom(buf, n, 0)); ASSERT_SYS(EFAULT, -1, getrandom(0, n, 0)); ASSERT_SYS(EINVAL, -1, getrandom(buf, n, -1)); if ((e = MeasureEntropy(buf, n)) < w) { fprintf(stderr, "error: entropy is suspect! got %g but want >=%g\n", e, w); for (i = 0; i < n;) { if (!(i % 16)) fprintf(stderr, "%6x ", i); fprintf(stderr, "%lc", kCp437[buf[i] & 255]); if (!(++i % 16)) fprintf(stderr, "\n"); } fprintf(stderr, "\n"); exit(1); } } TEST(getrandom, test2) { pthread_t child; double e, w = 7.7; struct sigaction sa; int i, j, k, m, n = 999; char *buf = _gc(calloc(1, n)); sa.sa_flags = 0; sa.sa_handler = OnSig; sigemptyset(&sa.sa_mask); ASSERT_SYS(0, 0, sigaction(SIGUSR1, &sa, 0)); ASSERT_SYS(0, 0, sigaction(SIGUSR2, &sa, 0)); parent = pthread_self(); ASSERT_EQ(0, pthread_create(&child, 0, TortureWorker, 0)); while (!ready) pthread_yield(); for (k = 0; k < 10; ++k) { ASSERT_SYS(0, 0, getrandom(0, 0, 0)); for (i = 0; i < n; i += m) { ASSERT_NE(-1, (m = getrandom(buf + i, n - i, 0))); } ASSERT_SYS(EFAULT, -1, getrandom(0, n, 0)); ASSERT_SYS(EINVAL, -1, getrandom(buf, n, -1)); if ((e = MeasureEntropy(buf, n)) < w) { fprintf(stderr, "error: entropy suspect! got %g but want >=%g\n", e, w); for (i = 0; i < n;) { if (!(i % 16)) fprintf(stderr, "%6x ", i); fprintf(stderr, "%lc", kCp437[buf[i] & 255]); if (!(++i % 16)) fprintf(stderr, "\n"); } fprintf(stderr, "\n"); done = true; pthread_join(child, 0); exit(1); } } done = true; ASSERT_EQ(0, pthread_join(child, 0)); if (!IsWindows()) ASSERT_GT(gotsome, 0); } /* JustReturnZero */ /* entropy: 0 */ /* chi-square: 2.55e+07 */ /* chi-square percent: 0 */ /* mean: 0 */ /* monte-carlo-pi: 27.324 */ /* serial-correlation: -100000 */ /* JustIncrement */ /* entropy: 2.63951 */ /* chi-square: 1.443e+07 */ /* chi-square percent: 0 */ /* mean: 18.8803 */ /* monte-carlo-pi: 27.324 */ /* serial-correlation: 0.0092003 */ /* UNIX Sixth Edition */ /* entropy: 8 */ /* chi-square: 0.1536 */ /* chi-square percent: 1 */ /* mean: 127.502 */ /* monte-carlo-pi: 3.4192 */ /* serial-correlation: -0.470645 */ /* UNIX Seventh Edition */ /* entropy: 7.99818 */ /* chi-square: 251.843 */ /* chi-square percent: 0.544128 */ /* mean: 127.955 */ /* monte-carlo-pi: 0.675703 */ /* serial-correlation: -0.00207669 */ /* KnuthLcg */ /* entropy: 7.99835 */ /* chi-square: 228.383 */ /* chi-square percent: 0.883476 */ /* mean: 127.1 */ /* monte-carlo-pi: 0.561935 */ /* serial-correlation: -0.0038954 */ /* rand64 */ /* entropy: 7.99832 */ /* chi-square: 233.267 */ /* chi-square percent: 0.831821 */ /* mean: 127.427 */ /* monte-carlo-pi: 0.0271532 */ /* serial-correlation: -0.00255319 */ /* Rand64LowByte */ /* entropy: 7.99798 */ /* chi-square: 278.344 */ /* chi-square percent: 0.150796 */ /* mean: 127.88 */ /* monte-carlo-pi: 0.00340573 */ /* serial-correlation: 0.00162231 */ /* GetRandomNoSystem */ /* entropy: 7.99819 */ /* chi-square: 249.743 */ /* chi-square percent: 0.58114 */ /* mean: 127.124 */ /* monte-carlo-pi: 0.293716 */ /* serial-correlation: 0.00198516 */ /* GetRandomNoRdrrnd */ /* entropy: 7.99816 */ /* chi-square: 254.797 */ /* chi-square percent: 0.491811 */ /* mean: 127.308 */ /* monte-carlo-pi: 0.0118738 */ /* serial-correlation: 0.000197669 */ /* GetRandom */ /* entropy: 7.99808 */ /* chi-square: 266.737 */ /* chi-square percent: 0.294131 */ /* mean: 127.178 */ /* monte-carlo-pi: 0.0577122 */ /* serial-correlation: 0.00598793 */ typedef uint64_t (*random_f)(void); static uint32_t randx = 1; uint64_t JustReturnZero(void) { return 0; } uint64_t JustIncrement(void) { static uint64_t x; return x++; } uint16_t SixthEditionRand(void) { static int16_t gorp; gorp = (gorp + 625) & 077777; return gorp; } uint64_t SixthEditionLowByte(void) { unsigned i; uint64_t x; for (x = i = 0; i < 8; ++i) { x <<= 8; x |= SixthEditionRand() & 255; } return x; } uint64_t MobyDick(void) { static int i; if ((i += 8) > kMobySize) i = 8; return READ64LE(kMoby + i); } uint64_t ExecutableImage(void) { static int i; if ((i += 8) > _end - __executable_start) i = 8; return READ64LE(__executable_start + i); } uint32_t SeventhEditionRand(void) { return ((randx = randx * 1103515245 + 12345) >> 16) & 077777; } uint64_t SeventhEditionLowByte(void) { unsigned i; uint64_t x; for (x = i = 0; i < 8; ++i) { x <<= 8; x |= SeventhEditionRand() & 255; } return x; } uint64_t KnuthLcg(void) { unsigned i; uint64_t x; for (x = i = 0; i < 8; ++i) { x <<= 8; x |= rand() & 255; } return x; } uint64_t Rand64LowByte(void) { unsigned i; uint64_t x; for (x = i = 0; i < 8; ++i) { x <<= 8; x |= _rand64() & 255; } return x; } uint64_t GetRandom(void) { uint64_t x; ASSERT_EQ(8, getrandom(&x, 8, 0)); return x; } static const struct RandomFunction { const char *s; random_f f; bool r; } kRandomFunctions[] = { {"JustReturnZero", JustReturnZero, false}, // {"JustIncrement", JustIncrement, false}, // {"MobyDick", MobyDick, false}, // {"ExecutableImage", ExecutableImage, false}, // {"SixthEditionLowByte", SixthEditionLowByte, false}, // {"SeventhEditionLowByte", SeventhEditionLowByte, false}, // {"KnuthLcg", KnuthLcg, false}, // {"rand64", _rand64, true}, // {"Rand64LowByte", Rand64LowByte, true}, // {"GetRandom", GetRandom, true}, // }; TEST(getrandom, sanityTest) { uint64_t q; size_t i, j, k; double montepi, chip, scc, mean, chisq, ent; for (k = 0; k < 1; ++k) { for (j = 0; j < ARRAYLEN(kRandomFunctions); ++j) { rt_init(0); for (i = 0; i + 8 <= 100000; i += 8) { q = kRandomFunctions[j].f(); rt_add(&q, 8); } rt_end(&ent, &chisq, &mean, &montepi, &scc); chip = pochisq(chisq, 255); #if 0 fprintf(stderr, "\n"); fprintf(stderr, "/* %-32s */\n", kRandomFunctions[j].s); fprintf(stderr, "/* entropy: %-12g */\n", ent); fprintf(stderr, "/* chi-square: %-12g */\n", chisq); fprintf(stderr, "/* chi-square percent: %-12g */\n", chip); fprintf(stderr, "/* mean: %-12g */\n", mean); fprintf(stderr, "/* monte-carlo-pi: %-12g */\n", 100 * fabs(M_PI - montepi) / M_PI); fprintf(stderr, "/* serial-correlation: %-12g */\n", scc); #endif if (kRandomFunctions[j].r) { CHECK_GT(chisq, 100, "%s", kRandomFunctions[j].s); CHECK_LT(chisq, 400, "%s", kRandomFunctions[j].s); CHECK_GE(ent * 10, 78, "%s", kRandomFunctions[j].s); CHECK_LT(fabs(scc) * 100, 5, "%s", kRandomFunctions[j].s); CHECK_LT(fabs(128 - mean), 3, "%s", kRandomFunctions[j].s); } } } } TEST(getrandom, badflags_einval) { ASSERT_SYS(EINVAL, -1, getrandom(0, 0, -1)); } #endif /* __aarch64__ */
11,256
347
jart/cosmopolitan
false
cosmopolitan/test/libc/stdio/memory_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" #include "libc/runtime/internal.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" #include "libc/thread/spawn.h" int Worker(void *arg, int tid) { int i; char *volatile p; char *volatile q; for (i = 0; i < 256; ++i) { p = malloc(17); free(p); p = malloc(17); q = malloc(17); sched_yield(); free(p); free(q); } return 0; } void SetUpOnce(void) { __enable_threads(); ASSERT_SYS(0, 0, pledge("stdio", 0)); } TEST(memory, test) { int i, n = 32; struct spawn *t = gc(malloc(sizeof(struct spawn) * n)); for (i = 0; i < n; ++i) ASSERT_SYS(0, 0, _spawn(Worker, 0, t + i)); for (i = 0; i < n; ++i) EXPECT_SYS(0, 0, _join(t + i)); }
2,620
54
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/formatbinary64_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" char buf[67]; void SetUp(void) { memset(buf, 0x55, sizeof(buf)); } TEST(FormatBinary64, test1) { EXPECT_EQ(1, FormatBinary64(buf, 0, 2) - buf); EXPECT_STREQ("0", buf); } TEST(FormatBinary64, test2) { EXPECT_EQ(1, FormatBinary64(buf, 0, 0) - buf); EXPECT_STREQ("0", buf); EXPECT_EQ(3, FormatBinary64(buf, 0, 1) - buf); EXPECT_STREQ("0b0", buf); } TEST(FormatBinary64, test3) { EXPECT_EQ(3, FormatBinary64(buf, 1, 2) - buf); EXPECT_STREQ("0b1", buf); } TEST(FormatBinary64, test4) { EXPECT_EQ(1, FormatBinary64(buf, 1, 0) - buf); EXPECT_STREQ("1", buf); } TEST(FormatBinary64, test5) { EXPECT_EQ(66, FormatBinary64(buf, 01777777777777777777777UL, 2) - buf); EXPECT_STREQ( "0b1111111111111111111111111111111111111111111111111111111111111111", buf); } TEST(FormatBinary64, test6) { EXPECT_EQ(64, FormatBinary64(buf, 01777777777777777777777UL, 0) - buf); EXPECT_STREQ( "1111111111111111111111111111111111111111111111111111111111111111", buf); } TEST(FormatBinary64, test7) { EXPECT_EQ(66, FormatBinary64(buf, 0xEBF2AA499B9028EAul, 2) - buf); EXPECT_STREQ( "0b1110101111110010101010100100100110011011100100000010100011101010", buf); } TEST(FormatBinary64, test8) { EXPECT_EQ(66, FormatBinary64(buf, 0x00F2AA499B9028EAul, 2) - buf); EXPECT_STREQ( "0b0000000011110010101010100100100110011011100100000010100011101010", buf); } TEST(FormatBinary64, testScalesToWordSizes) { EXPECT_EQ(8 + 2, FormatBinary64(buf, 13, 2) - buf); EXPECT_STREQ("0b00001101", buf); EXPECT_EQ(16 + 2, FormatBinary64(buf, 31337, 2) - buf); EXPECT_STREQ("0b0111101001101001", buf); EXPECT_EQ(32 + 2, FormatBinary64(buf, 65536, 2) - buf); EXPECT_STREQ("0b00000000000000010000000000000000", buf); } BENCH(FormatBinary64, bench) { EZBENCH2("FormatUint64 tiny", donothing, FormatUint64(buf, 1)); EZBENCH2("FormatOctal64 tiny", donothing, FormatOctal64(buf, 1, true)); EZBENCH2("FormatBinary64 tiny", donothing, FormatBinary64(buf, 1, 2)); EZBENCH2("FormatUint64 big", donothing, FormatUint64(buf, 01777777777777777777777UL)); EZBENCH2("FormatOctal64 big", donothing, FormatOctal64(buf, 01777777777777777777777UL, true)); EZBENCH2("FormatBinary64 big", donothing, FormatBinary64(buf, 01777777777777777777777UL, 2)); }
4,309
100
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/printf_uppercase_e_static_yoink_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2023 Gabriel Ravier │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/intrin/kprintf.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" // We specifically avoid the test framework because otherwise __fmt_dtoa is // always automatically pulled in from code in there - and this is what we're // testing for here int main() { char buffer[30]; int snprintf_result = snprintf(buffer, sizeof(buffer), "%E", .0); if (strcmp(buffer, "0.000000E+00")) { kprintf( "error: snprintf gave us '%s' instead of the expected '0.000000E+00'\n", buffer); abort(); } if (snprintf_result != 12) { kprintf("error: snprintf returned %d instead of 12\n", snprintf_result); abort(); } }
2,527
43
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/formatint64_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/conv.h" #include "libc/fmt/itoa.h" #include "libc/limits.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" TEST(FormatInt64, test) { char buf[21]; EXPECT_EQ(1, FormatInt64(buf, 0) - buf); EXPECT_STREQ("0", buf); EXPECT_EQ(1, FormatInt64(buf, 1) - buf); EXPECT_STREQ("1", buf); EXPECT_EQ(2, FormatInt64(buf, -1) - buf); EXPECT_STREQ("-1", buf); EXPECT_EQ(19, FormatInt64(buf, INT64_MAX) - buf); EXPECT_STREQ("9223372036854775807", buf); EXPECT_EQ(20, FormatInt64(buf, INT64_MIN) - buf); EXPECT_STREQ("-9223372036854775808", buf); } TEST(FormatUint64, test) { char buf[21]; EXPECT_EQ(1, FormatUint64(buf, 0) - buf); EXPECT_STREQ("0", buf); EXPECT_EQ(4, FormatUint64(buf, 1024) - buf); EXPECT_STREQ("1024", buf); EXPECT_EQ(20, FormatUint64(buf, UINT64_MAX) - buf); EXPECT_STREQ("18446744073709551615", buf); EXPECT_EQ(19, FormatUint64(buf, INT64_MIN) - buf); EXPECT_STREQ("9223372036854775808", buf); } TEST(int128toarray_radix10, test) { char buf[41]; EXPECT_EQ(1, int128toarray_radix10(0, buf)); EXPECT_STREQ("0", buf); EXPECT_EQ(39, int128toarray_radix10(INT128_MAX, buf)); EXPECT_STREQ("170141183460469231731687303715884105727", buf); EXPECT_EQ(40, int128toarray_radix10(INT128_MIN, buf)); EXPECT_STREQ("-170141183460469231731687303715884105728", buf); } TEST(uint128toarray_radix10, test) { char buf[40]; EXPECT_EQ(1, uint128toarray_radix10(0, buf)); EXPECT_STREQ("0", buf); EXPECT_EQ(39, uint128toarray_radix10(UINT128_MAX, buf)); EXPECT_STREQ("340282366920938463463374607431768211455", buf); EXPECT_EQ(39, uint128toarray_radix10(INT128_MIN, buf)); EXPECT_STREQ("170141183460469231731687303715884105728", buf); } BENCH(itoa64radix10, bench) { char b[21]; EZBENCH2("itoa64radix10", donothing, FormatUint64(b, UINT64_MAX)); }
3,680
75
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/formatflex64_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" char buf[25]; void SetUp(void) { memset(buf, 0x55, sizeof(buf)); } TEST(formatflex64, test) { EXPECT_EQ(5, FormatFlex64(buf, 31337, 2) - buf); EXPECT_STREQ("31337", buf); EXPECT_EQ(10, FormatFlex64(buf, 0x80000000, 2) - buf); EXPECT_STREQ("0x80000000", buf); }
2,223
36
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/zleb64_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/leb128.h" #include "libc/limits.h" #include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" #include "libc/testlib/testlib.h" TEST(zleb64, testZero) { int64_t x; char *p = gc(malloc(10)); EXPECT_EQ(1, zleb64(p, 0) - p); EXPECT_EQ(0, p[0] & 255); EXPECT_EQ(1, unzleb64(p, 10, &x)); EXPECT_EQ(0, x); } TEST(zleb64, testNegOne) { int64_t x; char *p = gc(malloc(10)); EXPECT_EQ(1, zleb64(p, -1) - p); EXPECT_EQ(1, p[0] & 255); EXPECT_EQ(1, unzleb64(p, 10, &x)); EXPECT_EQ(-1, x); } TEST(zleb64, testOne) { int64_t x; char *p = gc(malloc(10)); EXPECT_EQ(1, zleb64(p, 1) - p); EXPECT_EQ(2, p[0] & 255); EXPECT_EQ(1, unzleb64(p, 10, &x)); EXPECT_EQ(1, x); } TEST(zleb64, testMax) { int64_t x; char *p = gc(malloc(10)); EXPECT_EQ(10, zleb64(p, INT64_MAX) - p); EXPECT_EQ(254, p[0] & 255); EXPECT_EQ(255, p[1] & 255); EXPECT_EQ(255, p[2] & 255); EXPECT_EQ(255, p[3] & 255); EXPECT_EQ(255, p[4] & 255); EXPECT_EQ(255, p[5] & 255); EXPECT_EQ(255, p[6] & 255); EXPECT_EQ(255, p[7] & 255); EXPECT_EQ(255, p[8] & 255); EXPECT_EQ(1, p[9] & 255); EXPECT_EQ(10, unzleb64(p, 10, &x)); EXPECT_EQ(INT64_MAX, x); }
3,022
69
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/uleb64_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/leb128.h" #include "libc/limits.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" char p[10]; uint64_t x; TEST(uleb64, testZero) { EXPECT_EQ(1, uleb64(p, 0) - p); EXPECT_EQ(0, p[0]); EXPECT_EQ(1, unuleb64(p, 10, &x)); EXPECT_EQ(0, x); EXPECT_EQ(-1, unuleb64(p, 0, &x)); } TEST(uleb64, testOne) { EXPECT_EQ(1, uleb64(p, 1) - p); EXPECT_EQ(1, p[0]); EXPECT_EQ(1, unuleb64(p, 10, &x)); EXPECT_EQ(1, x); } TEST(uleb64, test255) { EXPECT_EQ(2, uleb64(p, 255) - p); EXPECT_EQ(255, p[0] & 255); EXPECT_EQ(1, p[1]); EXPECT_EQ(2, unuleb64(p, 10, &x)); EXPECT_EQ(255, x); } TEST(uleb64, testFFFF) { EXPECT_EQ(3, uleb64(p, 0xFFFF) - p); EXPECT_EQ(255, p[0] & 255); EXPECT_EQ(255, p[1] & 255); EXPECT_EQ(3, p[2] & 255); } TEST(uleb64, testMax) { EXPECT_EQ(10, uleb64(p, UINT64_MAX) - p); EXPECT_EQ(255, p[0x00] & 255); EXPECT_EQ(255, p[0x01] & 255); EXPECT_EQ(255, p[0x02] & 255); EXPECT_EQ(255, p[0x03] & 255); EXPECT_EQ(255, p[0x04] & 255); EXPECT_EQ(255, p[0x05] & 255); EXPECT_EQ(255, p[0x06] & 255); EXPECT_EQ(255, p[0x07] & 255); EXPECT_EQ(255, p[0x08] & 255); EXPECT_EQ(001, p[0x09] & 255); EXPECT_EQ(10, unuleb64(p, 10, &x)); EXPECT_EQ(UINT64_MAX, x); EXPECT_EQ(-1, unuleb64(p, 7, &x)); }
3,127
73
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/imaxdiv_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Hugues Morisset │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/conv.h" #include "libc/limits.h" #include "libc/testlib/testlib.h" TEST(imaxdiv, test) { imaxdiv_t res; res = imaxdiv(-5, 3); EXPECT_EQ(-1, res.quot); EXPECT_EQ(-2, res.rem); res = imaxdiv(1, 1); EXPECT_EQ(1, res.quot); EXPECT_EQ(0, res.rem); res = imaxdiv(20, 10); EXPECT_EQ(2, res.quot); EXPECT_EQ(0, res.rem); res = imaxdiv(20, 11); EXPECT_EQ(1, res.quot); EXPECT_EQ(9, res.rem); res = imaxdiv(-20, -11); EXPECT_EQ(1, res.quot); EXPECT_EQ(-9, res.rem); res = imaxdiv(0, -11); EXPECT_EQ(0, res.quot); EXPECT_EQ(0, res.rem); res = imaxdiv(0, 11); EXPECT_EQ(0, res.quot); EXPECT_EQ(0, res.rem); res = imaxdiv(INT64_MIN, 1); EXPECT_EQ(INT64_MIN, res.quot); EXPECT_EQ(0, res.rem); res = imaxdiv(INT64_MAX, -1); EXPECT_EQ(-(INT64_MAX), res.quot); EXPECT_EQ(0, res.rem); res = imaxdiv(2387, 348); EXPECT_EQ(6, res.quot); EXPECT_EQ(299, res.rem); }
2,772
66
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/palandprintf_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=8 sts=2 sw=2 fenc=utf-8 :vi│ ╚══════════════════════════════════════════════════════════════════════════════╝ │ @author (c) Marco Paland ([email protected]) │ │ 2014-2019, PALANDesign Hannover, Germany │ │ │ │ @license The MIT License (MIT) │ │ │ │ Permission is hereby granted, free of charge, to any person obtaining a copy │ │ of this software and associated documentation files (the "Software"), to deal│ │ in the Software without restriction, including without limitation the rights │ │ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell │ │ copies of the Software, and to permit persons to whom the Software is │ │ furnished to do so, subject to the following conditions: │ │ │ │ The above copyright notice and this permission notice shall be included in │ │ all copies or substantial portions of the Software. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR │ │ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, │ │ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE │ │ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER │ │ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,│ │ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN │ │ THE SOFTWARE. │ └─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" #include "libc/intrin/pushpop.h" #include "libc/intrin/safemacros.internal.h" #include "libc/limits.h" #include "libc/math.h" #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/xasprintf.h" char buffer[1000]; /* #define Format(...) _gc(xasprintf(__VA_ARGS__)) */ #define Format(...) (snprintf(buffer, sizeof(buffer), __VA_ARGS__), buffer) TEST(sprintf, test_space_flag) { EXPECT_STREQ(" 42", Format("% d", 42)); EXPECT_STREQ("-42", Format("% d", -42)); EXPECT_STREQ(" 42", Format("% 5d", 42)); EXPECT_STREQ(" -42", Format("% 5d", -42)); EXPECT_STREQ(" 42", Format("% 15d", 42)); EXPECT_STREQ(" -42", Format("% 15d", -42)); EXPECT_STREQ(" -42", Format("% 15d", -42)); EXPECT_STREQ(" -42.987", Format("% 15.3f", -42.987)); EXPECT_STREQ(" 42.987", Format("% 15.3f", 42.987)); EXPECT_STREQ("Hello testing", Format("% s", "Hello testing")); EXPECT_STREQ(" 1024", Format("% d", 1024)); EXPECT_STREQ("-1024", Format("% d", -1024)); EXPECT_STREQ(" 1024", Format("% i", 1024)); EXPECT_STREQ("-1024", Format("% i", -1024)); EXPECT_STREQ("1024", Format("% u", 1024)); EXPECT_STREQ("4294966272", Format("% u", 4294966272U)); EXPECT_STREQ("777", Format("% o", 511)); EXPECT_STREQ("37777777001", Format("% o", 4294966785U)); EXPECT_STREQ("1234abcd", Format("% x", 305441741)); EXPECT_STREQ("edcb5433", Format("% x", 3989525555U)); EXPECT_STREQ("1234ABCD", Format("% X", 305441741)); EXPECT_STREQ("EDCB5433", Format("% X", 3989525555U)); EXPECT_STREQ("x", Format("% c", 'x')); } TEST(sprintf, test_plus_flag) { EXPECT_STREQ("+42", Format("%+d", 42)); EXPECT_STREQ("-42", Format("%+d", -42)); EXPECT_STREQ(" +42", Format("%+5d", 42)); EXPECT_STREQ(" -42", Format("%+5d", -42)); EXPECT_STREQ(" +42", Format("%+15d", 42)); EXPECT_STREQ(" -42", Format("%+15d", -42)); EXPECT_STREQ("+1024", Format("%+d", 1024)); EXPECT_STREQ("-1024", Format("%+d", -1024)); EXPECT_STREQ("+1024", Format("%+i", 1024)); EXPECT_STREQ("-1024", Format("%+i", -1024)); EXPECT_STREQ("1024", Format("%+u", 1024)); EXPECT_STREQ("4294966272", Format("%+u", 4294966272U)); EXPECT_STREQ("777", Format("%+o", 511)); EXPECT_STREQ("37777777001", Format("%+o", 4294966785U)); EXPECT_STREQ("1234abcd", Format("%+x", 305441741)); EXPECT_STREQ("edcb5433", Format("%+x", 3989525555U)); EXPECT_STREQ("1234ABCD", Format("%+X", 305441741)); EXPECT_STREQ("EDCB5433", Format("%+X", 3989525555U)); EXPECT_STREQ("+", Format("%+.0d", 0)); } TEST(sprintf, test_flag0) { EXPECT_STREQ("42", Format("%0d", 42)); EXPECT_STREQ("42", Format("%0ld", 42L)); EXPECT_STREQ("-42", Format("%0d", -42)); EXPECT_STREQ("00042", Format("%05d", 42)); EXPECT_STREQ("-0042", Format("%05d", -42)); EXPECT_STREQ("000000000000042", Format("%015d", 42)); EXPECT_STREQ("-00000000000042", Format("%015d", -42)); EXPECT_STREQ("000000000042.12", Format("%015.2f", 42.1234)); EXPECT_STREQ("00000000042.988", Format("%015.3f", 42.9876)); EXPECT_STREQ("-00000042.98760", Format("%015.5f", -42.9876)); } TEST(sprintf, test_flag_minus) { EXPECT_STREQ("42", Format("%-d", 42)); EXPECT_STREQ("-42", Format("%-d", -42)); EXPECT_STREQ("42 ", Format("%-5d", 42)); EXPECT_STREQ("-42 ", Format("%-5d", -42)); EXPECT_STREQ("42 ", Format("%-15d", 42)); EXPECT_STREQ("-42 ", Format("%-15d", -42)); EXPECT_STREQ("42", Format("%-0d", 42)); EXPECT_STREQ("-42", Format("%-0d", -42)); EXPECT_STREQ("42 ", Format("%-05d", 42)); EXPECT_STREQ("-42 ", Format("%-05d", -42)); EXPECT_STREQ("42 ", Format("%-015d", 42)); EXPECT_STREQ("-42 ", Format("%-015d", -42)); EXPECT_STREQ("42", Format("%0-d", 42)); EXPECT_STREQ("-42", Format("%0-d", -42)); EXPECT_STREQ("42 ", Format("%0-5d", 42)); EXPECT_STREQ("-42 ", Format("%0-5d", -42)); EXPECT_STREQ("42 ", Format("%0-15d", 42)); EXPECT_STREQ("-42 ", Format("%0-15d", -42)); } TEST(sprintf, testAlternativeFormatting) { EXPECT_STREQ("0", Format("%#x", 0)); EXPECT_STREQ("", Format("%#.0x", 0)); EXPECT_STREQ("0", Format("%#.1x", 0)); EXPECT_STREQ("", Format("%#.0llx", (long long)0)); EXPECT_STREQ("0x0000614e", Format("%#.8x", 0x614e)); EXPECT_STREQ("0b110", Format("%#b", 6)); } TEST(sprintf, testHexBasePrefix_onlyConsumesLeadingZeroes) { /* TODO(jart): Upstream bug fix for this behavior. */ EXPECT_STREQ("0x01", Format("%#04x", 0x1)); EXPECT_STREQ("0x12", Format("%#04x", 0x12)); EXPECT_STREQ("0x123", Format("%#04x", 0x123)); EXPECT_STREQ("0x1234", Format("%#04x", 0x1234)); } TEST(sprintf, testBinaryBasePrefix_onlyConsumesLeadingZeroes) { EXPECT_STREQ("0b01", Format("%#04b", 0b1)); EXPECT_STREQ("0b10", Format("%#04b", 0b10)); EXPECT_STREQ("0b101", Format("%#04b", 0b101)); EXPECT_STREQ("0b1010", Format("%#04b", 0b1010)); } TEST(sprintf, testOctalBasePrefix_onlyConsumesLeadingZeroes) { EXPECT_STREQ("0001", Format("%#04o", 01)); EXPECT_STREQ("0010", Format("%#04o", 010)); EXPECT_STREQ("0101", Format("%#04o", 0101)); EXPECT_STREQ("01010", Format("%#04o", 01010)); } TEST(sprintf, test_specifier) { EXPECT_STREQ("Hello testing", Format("Hello testing")); EXPECT_STREQ("Hello testing", Format("%s", "Hello testing")); EXPECT_STREQ("1024", Format("%d", 1024)); EXPECT_STREQ("-1024", Format("%d", -1024)); EXPECT_STREQ("1024", Format("%i", 1024)); EXPECT_STREQ("-1024", Format("%i", -1024)); EXPECT_STREQ("1024", Format("%u", 1024)); EXPECT_STREQ("4294966272", Format("%u", 4294966272U)); EXPECT_STREQ("777", Format("%o", 511)); EXPECT_STREQ("37777777001", Format("%o", 4294966785U)); EXPECT_STREQ("1234abcd", Format("%x", 305441741)); EXPECT_STREQ("edcb5433", Format("%x", 3989525555U)); EXPECT_STREQ("1234ABCD", Format("%X", 305441741)); EXPECT_STREQ("EDCB5433", Format("%X", 3989525555U)); EXPECT_STREQ("%", Format("%%")); } TEST(sprintf, test_width) { EXPECT_STREQ("Hello testing", Format("%1s", "Hello testing")); EXPECT_STREQ("1024", Format("%1d", 1024)); EXPECT_STREQ("-1024", Format("%1d", -1024)); EXPECT_STREQ("1024", Format("%1i", 1024)); EXPECT_STREQ("-1024", Format("%1i", -1024)); EXPECT_STREQ("1024", Format("%1u", 1024)); EXPECT_STREQ("4294966272", Format("%1u", 4294966272U)); EXPECT_STREQ("777", Format("%1o", 511)); EXPECT_STREQ("37777777001", Format("%1o", 4294966785U)); EXPECT_STREQ("1234abcd", Format("%1x", 305441741)); EXPECT_STREQ("edcb5433", Format("%1x", 3989525555U)); EXPECT_STREQ("1234ABCD", Format("%1X", 305441741)); EXPECT_STREQ("EDCB5433", Format("%1X", 3989525555U)); EXPECT_STREQ("x", Format("%1c", 'x')); } TEST(sprintf, test_width_20) { /* TODO(jart): wut */ /* sprintf(buffer, "%20s", "Hello"); */ /* printf("'%s' %d\n", buffer, strlen(buffer)); */ /* EXPECT_STREQ(" Hello", buffer); */ EXPECT_STREQ(" 1024", Format("%20d", 1024)); EXPECT_STREQ(" -1024", Format("%20d", -1024)); EXPECT_STREQ(" 1024", Format("%20i", 1024)); EXPECT_STREQ(" -1024", Format("%20i", -1024)); EXPECT_STREQ(" 1024", Format("%20u", 1024)); EXPECT_STREQ(" 4294966272", Format("%20u", 4294966272U)); EXPECT_STREQ(" 777", Format("%20o", 511)); EXPECT_STREQ(" 37777777001", Format("%20o", 4294966785U)); EXPECT_STREQ(" 1234abcd", Format("%20x", 305441741)); EXPECT_STREQ(" edcb5433", Format("%20x", 3989525555U)); EXPECT_STREQ(" 1234ABCD", Format("%20X", 305441741)); EXPECT_STREQ(" EDCB5433", Format("%20X", 3989525555U)); EXPECT_STREQ(" x", Format("%20c", 'x')); } TEST(sprintf, test_width_star_20) { EXPECT_STREQ(" Hello", Format("%*s", 20, "Hello")); EXPECT_STREQ(" 1024", Format("%*d", 20, 1024)); EXPECT_STREQ(" -1024", Format("%*d", 20, -1024)); EXPECT_STREQ(" 1024", Format("%*i", 20, 1024)); EXPECT_STREQ(" -1024", Format("%*i", 20, -1024)); EXPECT_STREQ(" 1024", Format("%*u", 20, 1024)); EXPECT_STREQ(" 4294966272", Format("%*u", 20, 4294966272U)); EXPECT_STREQ(" 777", Format("%*o", 20, 511)); EXPECT_STREQ(" 37777777001", Format("%*o", 20, 4294966785U)); EXPECT_STREQ(" 1234abcd", Format("%*x", 20, 305441741)); EXPECT_STREQ(" edcb5433", Format("%*x", 20, 3989525555U)); EXPECT_STREQ(" 1234ABCD", Format("%*X", 20, 305441741)); EXPECT_STREQ(" EDCB5433", Format("%*X", 20, 3989525555U)); EXPECT_STREQ(" x", Format("%*c", 20, 'x')); } TEST(sprintf, test_width_minus_20) { EXPECT_STREQ("Hello ", Format("%-20s", "Hello")); EXPECT_STREQ("1024 ", Format("%-20d", 1024)); EXPECT_STREQ("-1024 ", Format("%-20d", -1024)); EXPECT_STREQ("1024 ", Format("%-20i", 1024)); EXPECT_STREQ("-1024 ", Format("%-20i", -1024)); EXPECT_STREQ("1024 ", Format("%-20u", 1024)); EXPECT_STREQ("1024.1234 ", Format("%-20.4f", 1024.1234)); EXPECT_STREQ("4294966272 ", Format("%-20u", 4294966272U)); EXPECT_STREQ("777 ", Format("%-20o", 511)); EXPECT_STREQ("37777777001 ", Format("%-20o", 4294966785U)); EXPECT_STREQ("1234abcd ", Format("%-20x", 305441741)); EXPECT_STREQ("edcb5433 ", Format("%-20x", 3989525555U)); EXPECT_STREQ("1234ABCD ", Format("%-20X", 305441741)); EXPECT_STREQ("EDCB5433 ", Format("%-20X", 3989525555U)); EXPECT_STREQ("x ", Format("%-20c", 'x')); EXPECT_STREQ("| 9| |9 | | 9|", Format("|%5d| |%-2d| |%5d|", 9, 9, 9)); EXPECT_STREQ("| 10| |10| | 10|", Format("|%5d| |%-2d| |%5d|", 10, 10, 10)); EXPECT_STREQ("| 9| |9 | | 9|", Format("|%5d| |%-12d| |%5d|", 9, 9, 9)); EXPECT_STREQ("| 10| |10 | | 10|", Format("|%5d| |%-12d| |%5d|", 10, 10, 10)); } TEST(sprintf, test_width_0_minus_20) { EXPECT_STREQ("Hello ", Format("%0-20s", "Hello")); EXPECT_STREQ("1024 ", Format("%0-20d", 1024)); EXPECT_STREQ("-1024 ", Format("%0-20d", -1024)); EXPECT_STREQ("1024 ", Format("%0-20i", 1024)); EXPECT_STREQ("-1024 ", Format("%0-20i", -1024)); EXPECT_STREQ("1024 ", Format("%0-20u", 1024)); EXPECT_STREQ("4294966272 ", Format("%0-20u", 4294966272U)); EXPECT_STREQ("777 ", Format("%0-20o", 511)); EXPECT_STREQ("37777777001 ", Format("%0-20o", 4294966785U)); EXPECT_STREQ("1234abcd ", Format("%0-20x", 305441741)); EXPECT_STREQ("edcb5433 ", Format("%0-20x", 3989525555U)); EXPECT_STREQ("1234ABCD ", Format("%0-20X", 305441741)); EXPECT_STREQ("EDCB5433 ", Format("%0-20X", 3989525555U)); EXPECT_STREQ("x ", Format("%0-20c", 'x')); } TEST(sprintf, test_padding_20) { EXPECT_STREQ("00000000000000001024", Format("%020d", 1024)); EXPECT_STREQ("-0000000000000001024", Format("%020d", -1024)); EXPECT_STREQ("00000000000000001024", Format("%020i", 1024)); EXPECT_STREQ("-0000000000000001024", Format("%020i", -1024)); EXPECT_STREQ("00000000000000001024", Format("%020u", 1024)); EXPECT_STREQ("00000000004294966272", Format("%020u", 4294966272U)); EXPECT_STREQ("00000000000000000777", Format("%020o", 511)); EXPECT_STREQ("00000000037777777001", Format("%020o", 4294966785U)); EXPECT_STREQ("0000000000001234abcd", Format("%020x", 305441741)); EXPECT_STREQ("000000000000edcb5433", Format("%020x", 3989525555U)); EXPECT_STREQ("0000000000001234ABCD", Format("%020X", 305441741)); EXPECT_STREQ("000000000000EDCB5433", Format("%020X", 3989525555U)); } TEST(sprintf, test_padding_dot_20) { EXPECT_STREQ("00000000000000001024", Format("%.20d", 1024)); EXPECT_STREQ("-00000000000000001024", Format("%.20d", -1024)); EXPECT_STREQ("00000000000000001024", Format("%.20i", 1024)); EXPECT_STREQ("-00000000000000001024", Format("%.20i", -1024)); EXPECT_STREQ("00000000000000001024", Format("%.20u", 1024)); EXPECT_STREQ("00000000004294966272", Format("%.20u", 4294966272U)); EXPECT_STREQ("00000000000000000777", Format("%.20o", 511)); EXPECT_STREQ("00000000037777777001", Format("%.20o", 4294966785U)); EXPECT_STREQ("0000000000001234abcd", Format("%.20x", 305441741)); EXPECT_STREQ("000000000000edcb5433", Format("%.20x", 3989525555U)); EXPECT_STREQ("0000000000001234ABCD", Format("%.20X", 305441741)); EXPECT_STREQ("000000000000EDCB5433", Format("%.20X", 3989525555U)); } TEST(sprintf, test_padding_pound_020) { EXPECT_STREQ("00000000000000001024", Format("%#020d", 1024)); EXPECT_STREQ("-0000000000000001024", Format("%#020d", -1024)); EXPECT_STREQ("00000000000000001024", Format("%#020i", 1024)); EXPECT_STREQ("-0000000000000001024", Format("%#020i", -1024)); EXPECT_STREQ("00000000000000001024", Format("%#020u", 1024)); EXPECT_STREQ("00000000004294966272", Format("%#020u", 4294966272U)); EXPECT_STREQ("00000000000000000777", Format("%#020o", 511)); EXPECT_STREQ("00000000037777777001", Format("%#020o", 4294966785U)); EXPECT_STREQ("0x00000000001234abcd", Format("%#020x", 305441741)); EXPECT_STREQ("0x0000000000edcb5433", Format("%#020x", 3989525555U)); EXPECT_STREQ("0X00000000001234ABCD", Format("%#020X", 305441741)); EXPECT_STREQ("0X0000000000EDCB5433", Format("%#020X", 3989525555U)); } TEST(sprintf, test_padding_pound_20) { EXPECT_STREQ(" 1024", Format("%#20d", 1024)); EXPECT_STREQ(" -1024", Format("%#20d", -1024)); EXPECT_STREQ(" 1024", Format("%#20i", 1024)); EXPECT_STREQ(" -1024", Format("%#20i", -1024)); EXPECT_STREQ(" 1024", Format("%#20u", 1024)); EXPECT_STREQ(" 4294966272", Format("%#20u", 4294966272U)); EXPECT_STREQ(" 0777", Format("%#20o", 511)); EXPECT_STREQ(" 037777777001", Format("%#20o", 4294966785U)); EXPECT_STREQ(" 0x1234abcd", Format("%#20x", 305441741)); EXPECT_STREQ(" 0xedcb5433", Format("%#20x", 3989525555U)); EXPECT_STREQ(" 0X1234ABCD", Format("%#20X", 305441741)); EXPECT_STREQ(" 0XEDCB5433", Format("%#20X", 3989525555U)); } TEST(sprintf, test_padding_20_point_5) { EXPECT_STREQ(" 01024", Format("%20.5d", 1024)); EXPECT_STREQ(" -01024", Format("%20.5d", -1024)); EXPECT_STREQ(" 01024", Format("%20.5i", 1024)); EXPECT_STREQ(" -01024", Format("%20.5i", -1024)); EXPECT_STREQ(" 01024", Format("%20.5u", 1024)); EXPECT_STREQ(" 4294966272", Format("%20.5u", 4294966272U)); EXPECT_STREQ(" 00777", Format("%20.5o", 511)); EXPECT_STREQ(" 37777777001", Format("%20.5o", 4294966785U)); EXPECT_STREQ(" 1234abcd", Format("%20.5x", 305441741)); EXPECT_STREQ(" 00edcb5433", Format("%20.10x", 3989525555U)); EXPECT_STREQ(" 1234ABCD", Format("%20.5X", 305441741)); EXPECT_STREQ(" 00EDCB5433", Format("%20.10X", 3989525555U)); } TEST(sprintf, test_padding_neg_numbers) { /* space padding */ EXPECT_STREQ("-5", Format("% 1d", -5)); EXPECT_STREQ("-5", Format("% 2d", -5)); EXPECT_STREQ(" -5", Format("% 3d", -5)); EXPECT_STREQ(" -5", Format("% 4d", -5)); /* zero padding */ EXPECT_STREQ("-5", Format("%01d", -5)); EXPECT_STREQ("-5", Format("%02d", -5)); EXPECT_STREQ("-05", Format("%03d", -5)); EXPECT_STREQ("-005", Format("%04d", -5)); } TEST(sprintf, test_float_padding_neg_numbers) { /* space padding */ EXPECT_STREQ("-5.0", Format("% 3.1f", -5.)); EXPECT_STREQ("-5.0", Format("% 4.1f", -5.)); EXPECT_STREQ(" -5.0", Format("% 5.1f", -5.)); /* zero padding */ EXPECT_STREQ("-5.0", Format("%03.1f", -5.)); EXPECT_STREQ("-5.0", Format("%04.1f", -5.)); EXPECT_STREQ("-05.0", Format("%05.1f", -5.)); /* zero padding no decimal point */ EXPECT_STREQ("-5", Format("%01.0f", -5.)); EXPECT_STREQ("-5", Format("%02.0f", -5.)); EXPECT_STREQ("-05", Format("%03.0f", -5.)); } TEST(sprintf, test_length) { EXPECT_STREQ("", Format("%.0s", "Hello testing")); EXPECT_STREQ(" ", Format("%20.0s", "Hello testing")); EXPECT_STREQ("", Format("%.s", "Hello testing")); EXPECT_STREQ(" ", Format("%20.s", "Hello testing")); EXPECT_STREQ(" 1024", Format("%20.0d", 1024)); EXPECT_STREQ(" -1024", Format("%20.0d", -1024)); EXPECT_STREQ(" ", Format("%20.d", 0)); EXPECT_STREQ(" 1024", Format("%20.0i", 1024)); EXPECT_STREQ(" -1024", Format("%20.i", -1024)); EXPECT_STREQ(" ", Format("%20.i", 0)); EXPECT_STREQ(" 1024", Format("%20.u", 1024)); EXPECT_STREQ(" 4294966272", Format("%20.0u", 4294966272U)); EXPECT_STREQ(" ", Format("%20.u", 0U)); EXPECT_STREQ(" 777", Format("%20.o", 511)); EXPECT_STREQ(" 37777777001", Format("%20.0o", 4294966785U)); EXPECT_STREQ(" ", Format("%20.o", 0U)); EXPECT_STREQ(" 1234abcd", Format("%20.x", 305441741)); EXPECT_STREQ(" 1234abcd", Format("%50.x", 305441741)); EXPECT_STREQ(" 1234abcd 12345", Format("%50.x%10.u", 305441741, 12345)); EXPECT_STREQ(" edcb5433", Format("%20.0x", 3989525555U)); EXPECT_STREQ(" ", Format("%20.x", 0U)); EXPECT_STREQ(" 1234ABCD", Format("%20.X", 305441741)); EXPECT_STREQ(" EDCB5433", Format("%20.0X", 3989525555U)); EXPECT_STREQ(" ", Format("%20.X", 0U)); EXPECT_STREQ(" ", Format("%02.0u", 0U)); EXPECT_STREQ(" ", Format("%02.0d", 0)); } TEST(sprintf, test_float) { #ifndef __FINITE_MATH_ONLY__ EXPECT_STREQ("nan", Format("%.4f", NAN)); #endif EXPECT_STREQ("-0.0000", Format("%.4f", -0.)); EXPECT_STREQ("3.1415", Format("%.4f", 3.1415354)); EXPECT_STREQ("30343.142", Format("%.3f", 30343.1415354)); EXPECT_STREQ("34", Format("%.0f", 34.1415354)); EXPECT_STREQ("1", Format("%.0f", 1.3)); EXPECT_STREQ("2", Format("%.0f", 1.55)); EXPECT_STREQ("1.6", Format("%.1f", 1.64)); EXPECT_STREQ("42.90", Format("%.2f", 42.8952)); EXPECT_STREQ("42.895200000", Format("%.9f", 42.8952)); EXPECT_STREQ("42.8952230000", Format("%.10f", 42.895223)); EXPECT_STREQ("42.89522312345678", Format("%.14f", 42.89522312345678)); EXPECT_STREQ("42.89522387654321", Format("%.14f", 42.89522387654321)); EXPECT_STREQ(" 42.90", Format("%6.2f", 42.8952)); EXPECT_STREQ("+42.90", Format("%+6.2f", 42.8952)); EXPECT_STREQ("+42.9", Format("%+5.1f", 42.9252)); EXPECT_STREQ("42.500000", Format("%f", 42.5)); EXPECT_STREQ("42.500000", Format("%lf", 42.5)); EXPECT_STREQ("42.5", Format("%.1f", 42.5)); EXPECT_STREQ("42167.000000", Format("%f", 42167.0)); EXPECT_STREQ("-12345.987654321", Format("%.9f", -12345.987654321)); EXPECT_STREQ("4.0", Format("%.1f", 3.999)); EXPECT_STREQ("4", Format("%.0f", 3.5)); EXPECT_STREQ("4", Format("%.0f", 4.5)); EXPECT_STREQ("3", Format("%.0f", 3.49)); EXPECT_STREQ("3.5", Format("%.1f", 3.49)); EXPECT_STREQ("a0.5 ", Format("a%-5.1f", 0.5)); EXPECT_STREQ("a0.5 end", Format("a%-5.1fend", 0.5)); EXPECT_STREQ("100000000000000000000.0", Format("%.1f", 1E20)); } TEST(sprintf, test_types) { EXPECT_STREQ("0", Format("%i", 0)); EXPECT_STREQ("1234", Format("%i", 1234)); EXPECT_STREQ("32767", Format("%i", 32767)); EXPECT_STREQ("-32767", Format("%i", -32767)); EXPECT_STREQ("30", Format("%li", 30L)); EXPECT_STREQ("-2147483647", Format("%li", -2147483647L)); EXPECT_STREQ("2147483647", Format("%li", 2147483647L)); EXPECT_STREQ("30", Format("%lli", 30LL)); EXPECT_STREQ("-9223372036854775807", Format("%lli", -9223372036854775807LL)); EXPECT_STREQ("9223372036854775807", Format("%lli", 9223372036854775807LL)); EXPECT_STREQ("100000", Format("%lu", 100000L)); EXPECT_STREQ("4294967295", Format("%lu", 0xFFFFFFFFL)); EXPECT_STREQ("281474976710656", Format("%llu", 281474976710656LLU)); EXPECT_STREQ("18446744073709551615", Format("%llu", 18446744073709551615LLU)); EXPECT_STREQ("2147483647", Format("%zu", 2147483647UL)); EXPECT_STREQ("2147483647", Format("%zd", 2147483647UL)); if (sizeof(size_t) == sizeof(long)) { EXPECT_STREQ("-2147483647", Format("%zi", -2147483647L)); } else { EXPECT_STREQ("-2147483647", Format("%zi", -2147483647LL)); } EXPECT_STREQ("1110101001100000", Format("%b", 60000)); EXPECT_STREQ("101111000110000101001110", Format("%lb", 12345678L)); EXPECT_STREQ("165140", Format("%o", 60000)); EXPECT_STREQ("57060516", Format("%lo", 12345678L)); EXPECT_STREQ("12345678", Format("%lx", 0x12345678L)); EXPECT_STREQ("1234567891234567", Format("%llx", 0x1234567891234567LLU)); EXPECT_STREQ("abcdefab", Format("%lx", 0xabcdefabL)); EXPECT_STREQ("ABCDEFAB", Format("%lX", 0xabcdefabL)); EXPECT_STREQ("v", Format("%c", 'v')); EXPECT_STREQ("wv", Format("%cv", 'w')); EXPECT_STREQ("A Test", Format("%s", "A Test")); EXPECT_STREQ("255", Format("%hhu", 0xFFFFUL)); EXPECT_STREQ("a", Format("%tx", &buffer[10] - &buffer[0])); /* TBD */ EXPECT_STREQ("-2147483647", Format("%ji", (intmax_t)-2147483647L)); } TEST(sprintf, testOverflow_truncationNotSaturation) { errno = 0; EXPECT_STREQ("13398", Format("%hu", 0x123456UL)); errno = 0; EXPECT_STREQ("Test16 65535", Format("%s%hhi %hu", "Test", 10000, 0xFFFFFFFF)); } TEST(sprintf, test_unknown_flag) { EXPECT_STREQ("kmarco", Format("%kmarco", 42, 37)); } TEST(sprintf, test_buffer_length) { int ret; /* EXPECT_EQ(4, snprintf(pushpop(NULL), 10, "%s", "Test")); */ EXPECT_EQ(4, snprintf(pushpop(NULL), 0, "%s", "Test")); buffer[0] = (char)0xA5; ret = snprintf(buffer, 0, "%s", "Test"); EXPECT_TRUE(buffer[0] == (char)0xA5); EXPECT_TRUE(ret == 4); buffer[0] = (char)0xCC; snprintf(buffer, 1, "%s", pushpop(&"Test"[0])); EXPECT_TRUE(buffer[0] == '\0'); snprintf(buffer, 2, "%s", pushpop(&"Hello"[0])); EXPECT_STREQ("H", buffer); } TEST(sprintf, test_ret_value) { int ret; ret = snprintf(buffer, 6, "0%s", "1234"); EXPECT_STREQ("01234", buffer); EXPECT_TRUE(ret == 5); ret = snprintf(buffer, 6, "0%s", pushpop(&"12345"[0])); EXPECT_STREQ("01234", buffer); EXPECT_TRUE(ret == 6); /* '5' is truncated */ ret = snprintf(buffer, 6, "0%s", pushpop(&"1234567"[0])); EXPECT_STREQ("01234", buffer); EXPECT_TRUE(ret == 8); /* '567' are truncated */ ret = snprintf(buffer, 10, pushpop(&"hello, world"[0])); EXPECT_TRUE(ret == 12); ret = snprintf(buffer, 3, "%d", pushpop(10000)); EXPECT_TRUE(ret == 5); EXPECT_TRUE(strlen(buffer) == 2U); EXPECT_TRUE(buffer[0] == '1'); EXPECT_TRUE(buffer[1] == '0'); EXPECT_TRUE(buffer[2] == '\0'); } TEST(sprintf, test_misc) { EXPECT_STREQ("53000atest-20 bit", Format("%u%u%ctest%d %s", 5, 3000, 'a', -20, "bit")); EXPECT_STREQ("0.33", Format("%.*f", 2, 0.33333333)); EXPECT_STREQ("1", Format("%.*d", -1, 1)); EXPECT_STREQ("foo", Format("%.3s", "foobar")); EXPECT_STREQ(" ", Format("% .0d", 0)); EXPECT_STREQ(" 00004", Format("%10.5d", 4)); EXPECT_STREQ("hi x", Format("%*sx", -3, "hi")); } TEST(sprintf, test_snprintf) { snprintf(buffer, 100U, "%d", -1000); EXPECT_STREQ("-1000", buffer); snprintf(buffer, 3U, "%d", pushpop(-1000)); EXPECT_STREQ("-1", buffer); } void vsnprintf_builder_1(char *buf, ...) { va_list args; va_start(args, buf); vsnprintf(buf, 100U, "%d", args); va_end(args); } void vsnprintf_builder_3(char *buf, ...) { va_list args; va_start(args, buf); vsnprintf(buf, 100U, "%d %d %s", args); va_end(args); } TEST(sprintf, test_vsnprintf) { vsnprintf_builder_1(buffer, -1); EXPECT_STREQ("-1", buffer); vsnprintf_builder_3(buffer, 3, -1000, "test"); EXPECT_STREQ("3 -1000 test", buffer); } TEST(xasprintf, test) { void *pp; ASSERT_STREQ("hello 123", (pp = xasprintf("hello %d", 123))); free(pp); } TEST(xasprintf, hugeNtoa) { ASSERT_STREQ( "0b1111111111111111111111111111111111111111111111111111111111111111111111" "1111111111111111111111111111111111111111111111111111111111", _gc(xasprintf("%#jjb", UINT128_MAX))); } TEST(xasprintf, twosBane) { ASSERT_STREQ("-2147483648", _gc(xasprintf("%d", 0x80000000))); ASSERT_STREQ("-9223372036854775808", _gc(xasprintf("%ld", 0x8000000000000000))); } TEST(snprintf, testFixedWidthString_wontOverrunInput) { const int N = 2; char *buf = malloc(N + 1); char *inp = memcpy(malloc(N), "hi", N); EXPECT_EQ(2, snprintf(buf, N + 1, "%.*s", N, inp)); EXPECT_BINEQ(u"hi ", buf); free(inp); free(buf); } TEST(snprintf, testFixedWidthStringIsNull_wontOverrunBuffer) { int N = 3; char *buf = malloc(N + 1); EXPECT_EQ(3, snprintf(buf, N + 1, "%.*s", pushpop(N), pushpop(NULL))); EXPECT_STREQ("(nu", buf); EXPECT_EQ(3, snprintf(buf, N + 1, "%#.*s", pushpop(N), pushpop(NULL))); EXPECT_STREQ("(nu", buf); EXPECT_EQ(3, snprintf(buf, N + 1, "%`'.*s", pushpop(N), pushpop(NULL))); EXPECT_STREQ("NUL", buf); EXPECT_EQ(3, snprintf(buf, N + 1, "%`#.*s", pushpop(N), pushpop(NULL))); EXPECT_STREQ("NUL", buf); free(buf); } TEST(snprintf, twosBaneWithTypePromotion) { int16_t x = 0x8000; EXPECT_STREQ("-32768", Format("%hd", x)); } TEST(snprintf, formatStringLiteral) { EXPECT_EQ('\\' | 'n' << 8, _cescapec('\n')); EXPECT_EQ('\\' | '3' << 8 | '7' << 16 | '7' << 24, _cescapec('\377')); EXPECT_STREQ("\"hi\\n\"", Format("%`'s", "hi\n")); EXPECT_STREQ("\"\\000\"", Format("%`'.*s", 1, "\0")); } TEST(palandprintf, precisionStillRespectsNulTerminatorIfNotEscOrRepr) { EXPECT_STREQ("Makefile - 25 lines ", Format("%.20s - %d lines %s", "Makefile", 25, "")); } TEST(sprintf, commas) { char buf[64]; sprintf(buf, "%,d", 123456789); ASSERT_STREQ("123,456,789", buf); } TEST(vsnprintf, issue785) { ASSERT_EQ(0, snprintf(0, 0, "%s", "")); ASSERT_EQ(1, snprintf(0, 0, "%s", " ")); ASSERT_EQ(2, snprintf(0, 0, "%s", " ")); } BENCH(palandprintf, bench) { EZBENCH2("ascii", donothing, Format(VEIL("r", "hiuhcreohucreo"))); EZBENCH2("ascii %s", donothing, Format("%s", VEIL("r", "hiuhcreohucreo"))); EZBENCH2("ascii %`'s", donothing, Format("%`'s", VEIL("r", "hiuhcreohucre"))); EZBENCH2("utf8 %s", donothing, Format("%s", VEIL("r", "hi (╯°□°)╯"))); EZBENCH2("snprintf %hs", donothing, Format("%hs", VEIL("r", u"hi (╯°□°)╯"))); EZBENCH2("snprintf %ls", donothing, Format("%ls", VEIL("r", L"hi (╯°□°)╯"))); EZBENCH2("23 %x", donothing, Format("%x", VEIL("r", 23))); EZBENCH2("23 %d", donothing, Format("%d", VEIL("r", 23))); EZBENCH2("%f M_PI", donothing, Format("%f", VEIL("x", M_PI))); EZBENCH2("%g M_PI", donothing, Format("%g", VEIL("x", M_PI))); EZBENCH2("%a M_PI", donothing, Format("%a", VEIL("x", M_PI))); EZBENCH2("%e M_PI", donothing, Format("%e", VEIL("x", M_PI))); EZBENCH2("ULONG_MAX %lo", donothing, Format("%lo", VEIL("r", ULONG_MAX))); EZBENCH2("INT_MIN %x", donothing, Format("%x", VEIL("r", INT_MIN))); EZBENCH2("INT_MIN %d", donothing, Format("%d", VEIL("r", INT_MIN))); EZBENCH2("INT_MIN %,d", donothing, Format("%,d", VEIL("r", INT_MIN))); EZBENCH2("INT_MIN %ld", donothing, Format("%ld", (long)VEIL("r", INT_MIN))); EZBENCH2("LONG_MIN %lx", donothing, Format("%lx", VEIL("r", LONG_MIN))); EZBENCH2("LONG_MIN %ld", donothing, Format("%ld", VEIL("r", LONG_MIN))); EZBENCH2("INT128_MIN %jjd", donothing, Format("%jjd", INT128_MIN)); EZBENCH2("INT128_MIN %jjx", donothing, Format("%jjx", INT128_MIN)); EZBENCH2("int64toarray 23", donothing, FormatInt64(buffer, 23)); EZBENCH2("int64toarray min", donothing, FormatInt64(buffer, INT_MIN)); #ifdef __x86__ EZBENCH2("%Lf M_PI", donothing, Format("%Lf", VEIL("t", M_PI))); EZBENCH2("%Lg M_PI", donothing, Format("%Lg", VEIL("t", M_PI))); EZBENCH2("%La M_PI", donothing, Format("%La", VEIL("t", M_PI))); EZBENCH2("%Le M_PI", donothing, Format("%Le", VEIL("t", M_PI))); #endif }
31,085
668
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/formatint64thousands_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/conv.h" #include "libc/fmt/itoa.h" #include "libc/limits.h" #include "libc/macros.internal.h" #include "libc/math.h" #include "libc/stdio/stdio.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" TEST(FormatUint64Thousands, test) { char s[27]; EXPECT_EQ(s + 1, FormatUint64Thousands(s, 0)); EXPECT_STREQ("0", s); EXPECT_EQ(s + 1, FormatUint64Thousands(s, 1)); EXPECT_STREQ("1", s); EXPECT_EQ(s + 3, FormatUint64Thousands(s, 999)); EXPECT_STREQ("999", s); EXPECT_EQ(s + 5, FormatUint64Thousands(s, 1000)); EXPECT_STREQ("1,000", s); EXPECT_EQ(s + 7, FormatUint64Thousands(s, 999999)); EXPECT_STREQ("999,999", s); EXPECT_EQ(s + 9, FormatUint64Thousands(s, 1000000)); EXPECT_STREQ("1,000,000", s); EXPECT_EQ(s + 7, FormatUint64Thousands(s, 104040)); EXPECT_STREQ("104,040", s); } TEST(FormatInt64Thousands, testPositive) { char s[27]; EXPECT_EQ(s + 1, FormatInt64Thousands(s, 0)); EXPECT_STREQ("0", s); EXPECT_EQ(s + 1, FormatInt64Thousands(s, 1)); EXPECT_STREQ("1", s); EXPECT_EQ(s + 3, FormatInt64Thousands(s, 999)); EXPECT_STREQ("999", s); EXPECT_EQ(s + 5, FormatInt64Thousands(s, 1000)); EXPECT_STREQ("1,000", s); EXPECT_EQ(s + 7, FormatInt64Thousands(s, 999999)); EXPECT_STREQ("999,999", s); EXPECT_EQ(s + 9, FormatInt64Thousands(s, 1000000)); EXPECT_STREQ("1,000,000", s); } TEST(FormatInt64Thousands, testNegative) { char s[27]; EXPECT_EQ(s + 2, FormatInt64Thousands(s, -1)); EXPECT_STREQ("-1", s); EXPECT_EQ(s + 4, FormatInt64Thousands(s, -999)); EXPECT_STREQ("-999", s); EXPECT_EQ(s + 6, FormatInt64Thousands(s, -1000)); EXPECT_STREQ("-1,000", s); EXPECT_EQ(s + 8, FormatInt64Thousands(s, -999999)); EXPECT_STREQ("-999,999", s); EXPECT_EQ(s + 10, FormatInt64Thousands(s, -1000000)); EXPECT_STREQ("-1,000,000", s); } BENCH(FormatInt64Thousands, bench) { char s[27]; EZBENCH2("FormatInt64Thousands(MAX)", donothing, FormatInt64Thousands(s, INT64_MAX)); EZBENCH2("FormatInt64Thousands(MIN)", donothing, FormatInt64Thousands(s, INT64_MIN)); EZBENCH2("FormatUint64Thousands(MIN)", donothing, FormatUint64Thousands(s, UINT64_MAX)); }
4,030
85
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/joinpaths_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/str/path.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" char b[PATH_MAX]; TEST(xjoinpaths, test) { EXPECT_EQ(NULL, _joinpaths(b, sizeof(b), 0, 0)); EXPECT_STREQ("x", _joinpaths(b, sizeof(b), "x", 0)); EXPECT_STREQ("x", _joinpaths(b, sizeof(b), 0, "x")); EXPECT_STREQ("", _joinpaths(b, sizeof(b), "", "")); EXPECT_STREQ("", _joinpaths(b, sizeof(b), "", 0)); EXPECT_STREQ("", _joinpaths(b, sizeof(b), 0, "")); EXPECT_STREQ("", _joinpaths(b, sizeof(b), "", "")); EXPECT_STREQ("b", _joinpaths(b, sizeof(b), "", "b")); EXPECT_STREQ("a/", _joinpaths(b, sizeof(b), "a", "")); EXPECT_STREQ("a/b", _joinpaths(b, sizeof(b), "a", "b")); EXPECT_STREQ("a/b", _joinpaths(b, sizeof(b), "a/", "b")); EXPECT_STREQ("a/b/", _joinpaths(b, sizeof(b), "a", "b/")); EXPECT_STREQ("/b", _joinpaths(b, sizeof(b), "a", "/b")); EXPECT_STREQ("./b", _joinpaths(b, sizeof(b), ".", "b")); EXPECT_STREQ("b/.", _joinpaths(b, sizeof(b), "b", ".")); EXPECT_EQ(NULL, _joinpaths(b, 3, "a", "b/")); EXPECT_EQ(NULL, _joinpaths(b, 4, "a", "b/")); EXPECT_STREQ("a/b", _joinpaths(b, 4, "a/", "b")); EXPECT_STREQ("a/b/", _joinpaths(b, 5, "a", "b/")); } BENCH(joinpaths, bench) { EZBENCH2("_joinpaths", donothing, _joinpaths(b, sizeof(b), "care", "bear")); EZBENCH2("xjoinpaths", donothing, free(xjoinpaths("care", "bear"))); }
3,251
53
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/sizetol_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/testlib/testlib.h" TEST(sizetol, test) { EXPECT_EQ(-1, sizetol("", 1000)); EXPECT_EQ(0, sizetol("0", 1000)); EXPECT_EQ(0, sizetol("0kb", 1000)); EXPECT_EQ(31337, sizetol("31337", 1000)); EXPECT_EQ(+123, sizetol("+123", 1000)); EXPECT_EQ(-123, sizetol("-123", 1000)); EXPECT_EQ(1000, sizetol("1kb", 1000)); EXPECT_EQ(-1000, sizetol("-1kb", 1000)); EXPECT_EQ(2000, sizetol("2k", 1000)); EXPECT_EQ(1024, sizetol("1kb", 1024)); EXPECT_EQ(2048, sizetol("2k", 1024)); EXPECT_EQ(100000000, sizetol("100mb", 1000)); EXPECT_EQ(100000000000000, sizetol("100tb", 1000)); EXPECT_EQ(104857600, sizetol("100mb", 1024)); EXPECT_EQ(100000000, sizetol("100MB", 1000)); EXPECT_EQ(104857600, sizetol("100MB", 1024)); EXPECT_EQ(100000000, sizetol("100M", 1000)); EXPECT_EQ(104857600, sizetol("100M", 1024)); EXPECT_EQ(100000000, sizetol(" 100M", 1000)); EXPECT_EQ(104857600, sizetol("\t100M", 1024)); EXPECT_EQ(100, sizetol(" 100", 1000)); EXPECT_EQ(100, sizetol("\t100", 1024)); EXPECT_EQ(100, sizetol(" 100 ", 1000)); EXPECT_EQ(100, sizetol("\t100\t", 1024)); } TEST(sizetol, testOverflow_isDetected) { EXPECT_EQ(9000000000000000000, sizetol("9eb", 1000)); EXPECT_SYS(EOVERFLOW, -1, sizetol("10eb", 1000)); } TEST(sizetol, badSyntax) { EXPECT_SYS(EINVAL, -1, sizetol("- 1", 1000)); EXPECT_SYS(EINVAL, -1, sizetol("- 1", 1000)); EXPECT_SYS(EOVERFLOW, -1, sizetol("10eb", 1000)); }
3,325
60
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/formatoctal64_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/itoa.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" char buf[24]; void SetUp(void) { memset(buf, 0x55, sizeof(buf)); } TEST(FormatOctal64, test1) { EXPECT_EQ(1, FormatOctal64(buf, 0, true) - buf); EXPECT_STREQ("0", buf); } TEST(FormatOctal64, test2) { EXPECT_EQ(1, FormatOctal64(buf, 0, false) - buf); EXPECT_STREQ("0", buf); } TEST(FormatOctal64, test3) { EXPECT_EQ(2, FormatOctal64(buf, 1, true) - buf); EXPECT_STREQ("01", buf); } TEST(FormatOctal64, test4) { EXPECT_EQ(1, FormatOctal64(buf, 1, false) - buf); EXPECT_STREQ("1", buf); } TEST(FormatOctal64, test5) { EXPECT_EQ(23, FormatOctal64(buf, 01777777777777777777777UL, true) - buf); EXPECT_STREQ("01777777777777777777777", buf); } TEST(FormatOctal64, test6) { EXPECT_EQ(22, FormatOctal64(buf, 01777777777777777777777UL, false) - buf); EXPECT_STREQ("1777777777777777777777", buf); } BENCH(FormatOctal64, bench) { EZBENCH2("FormatUint64", donothing, FormatUint64(buf, 01777777777777777777777UL)); EZBENCH2("FormatOctal64", donothing, FormatOctal64(buf, 01777777777777777777777UL, true)); EZBENCH2("FormatOctal32", donothing, FormatOctal32(buf, 037777777777U, true)); }
3,093
67
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/printf_uppercase_g_static_yoink_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2023 Gabriel Ravier │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/intrin/kprintf.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" // We specifically avoid the test framework because otherwise __fmt_dtoa is // always automatically pulled in from code in there - and this is what we're // testing for here int main() { char buffer[30]; int snprintf_result = snprintf(buffer, sizeof(buffer), "%G", .0); if (strcmp(buffer, "0")) { kprintf("error: snprintf gave us '%s' instead of the expected '0'\n", buffer); abort(); } if (snprintf_result != 1) { kprintf("error: snprintf returned %d instead of 1\n", snprintf_result); abort(); } }
2,498
42
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/lengthuint64_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/itoa.h" #include "libc/limits.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" TEST(LengthUint64Thousands, test) { int i; char s[27]; static const uint64_t v[] = { 9, 10, 11, 99, 100, 101, 999, 1000, 1001, 999999, 1000000, 1000001, UINT64_MIN, UINT64_MAX, UINT64_MIN + 1, UINT64_MAX - 1, 0x8000000000000001ull, 0x8000000000000000ull, }; for (i = 0; i < ARRAYLEN(v); ++i) { FormatUint64Thousands(s, v[i]); ASSERT_EQ(strlen(s), LengthUint64Thousands(v[i]), "%,lu", v[i]); } } TEST(LengthInt64Thousands, test) { int i; char s[27]; static const int64_t v[] = { -1000001, -1000000, -999999, -1001, -1000, -999, -101, -100, -99, -11, -10, -9, -1, 0, 1, 9, 10, 11, 99, 100, 101, 999, 1000, 1001, 999999, 1000000, 1000001, INT64_MIN, INT64_MAX, INT64_MIN + 1, INT64_MAX - 1, }; for (i = 0; i < ARRAYLEN(v); ++i) { FormatInt64Thousands(s, v[i]); ASSERT_EQ(strlen(s), LengthInt64Thousands(v[i]), "%,ld\n\t%s\n\t%lx", v[i], s, v[i]); } } BENCH(LengthInt64, bench) { unsigned LengthInt64_(int64_t) asm("LengthInt64"); unsigned LengthUint64_(uint64_t) asm("LengthUint64"); unsigned LengthInt64Thousands_(int64_t) asm("LengthInt64Thousands"); unsigned LengthUint64Thousands_(uint64_t) asm("LengthUint64Thousands"); EZBENCH2("LengthInt64", donothing, LengthInt64_(INT64_MIN)); EZBENCH2("LengthUint64", donothing, LengthUint64_(UINT64_MAX)); EZBENCH2("LengthInt64Thousands", donothing, LengthInt64Thousands_(INT64_MIN)); EZBENCH2("LengthUint64Thousands", donothing, LengthUint64Thousands_(UINT64_MAX)); }
3,770
108
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/basename_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" #include "libc/fmt/conv.h" #include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" #include "libc/testlib/testlib.h" #define BASENAME(x) basename(gc(strdup(x))) TEST(basename, testRegularExamples) { EXPECT_STREQ("lib", BASENAME("/usr/lib")); EXPECT_STREQ("lib", BASENAME("usr/lib")); EXPECT_STREQ("usr", BASENAME("/usr/")); EXPECT_STREQ("usr", BASENAME("usr")); EXPECT_STREQ("/", BASENAME("/")); EXPECT_STREQ(".", BASENAME(".")); EXPECT_STREQ("..", BASENAME("..")); } TEST(basename, testIrregularExamples) { EXPECT_STREQ(".", basename(0)); EXPECT_STREQ(".", basename("")); } TEST(basename, testTrailingSlash_isIgnored) { EXPECT_STREQ("foo", BASENAME("foo/")); EXPECT_STREQ("foo", BASENAME("foo//")); } TEST(basename, testOnlySlashes_oneSlashOnlyVasily) { EXPECT_STREQ("/", BASENAME("///")); } TEST(basename, testWindows_isGrantedRespect) { EXPECT_STREQ("there", BASENAME("hello\\there")); EXPECT_STREQ("yo", BASENAME("hello\\there\\yo")); }
2,845
55
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/formatoctal32_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/itoa.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" char buf[13]; void SetUp(void) { memset(buf, 0x55, sizeof(buf)); } TEST(FormatOctal32, test1) { EXPECT_EQ(1, FormatOctal32(buf, 0, true) - buf); EXPECT_STREQ("0", buf); } TEST(FormatOctal32, test2) { EXPECT_EQ(1, FormatOctal32(buf, 0, false) - buf); EXPECT_STREQ("0", buf); } TEST(FormatOctal32, test3) { EXPECT_EQ(2, FormatOctal32(buf, 1, true) - buf); EXPECT_STREQ("01", buf); } TEST(FormatOctal32, test4) { EXPECT_EQ(1, FormatOctal32(buf, 1, false) - buf); EXPECT_STREQ("1", buf); } TEST(FormatOctal32, test5) { EXPECT_EQ(12, FormatOctal32(buf, 037777777777, true) - buf); EXPECT_STREQ("037777777777", buf); } TEST(FormatOctal32, test6) { EXPECT_EQ(11, FormatOctal32(buf, 037777777777, false) - buf); EXPECT_STREQ("37777777777", buf); }
2,697
58
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/fprintf_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2023 Gabriel Ravier │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" TEST(fprintf, testWriteError) { // Only Linux, NetBSD and FreeBSD are known to have /dev/full if (!IsLinux() && !IsNetbsd() && !IsFreebsd()) return; FILE *fp = fopen("/dev/full", "w"); ASSERT_NE(fp, NULL); setbuf(fp, NULL); ASSERT_LT(fprintf(fp, "test"), 0); ASSERT_EQ(fclose(fp), 0); }
2,227
35
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/fmt_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/limits.h" #include "libc/log/log.h" #include "libc/math.h" #include "libc/mem/gc.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" #include "libc/x/xasprintf.h" TEST(fmt, d) { EXPECT_STREQ("-123", _gc(xasprintf("%d", -123))); EXPECT_STREQ("-1", _gc(xasprintf("%d", -1))); EXPECT_STREQ("1", _gc(xasprintf("%d", 1))); EXPECT_STREQ("16", _gc(xasprintf("%d", 16))); EXPECT_STREQ("2147483647", _gc(xasprintf("%d", INT_MAX))); EXPECT_STREQ("-2147483648", _gc(xasprintf("%d", INT_MIN))); EXPECT_STREQ(" -123", _gc(xasprintf("%10d", -123))); EXPECT_STREQ(" -1", _gc(xasprintf("%10d", -1))); EXPECT_STREQ(" 1", _gc(xasprintf("%10d", 1))); EXPECT_STREQ(" 16", _gc(xasprintf("%10d", 16))); EXPECT_STREQ("2147483647", _gc(xasprintf("%10d", INT_MAX))); EXPECT_STREQ("-2147483648", _gc(xasprintf("%10d", INT_MIN))); EXPECT_STREQ("-000000123", _gc(xasprintf("%010d", -123))); EXPECT_STREQ("-000000001", _gc(xasprintf("%010d", -1))); EXPECT_STREQ("0000000001", _gc(xasprintf("%010d", 1))); EXPECT_STREQ("0000000016", _gc(xasprintf("%010d", 16))); EXPECT_STREQ("2147483647", _gc(xasprintf("%010d", INT_MAX))); EXPECT_STREQ("-2147483648", _gc(xasprintf("%010d", INT_MIN))); EXPECT_STREQ("-123 ", _gc(xasprintf("%-10d", -123))); EXPECT_STREQ("-1 ", _gc(xasprintf("%-10d", -1))); EXPECT_STREQ("1 ", _gc(xasprintf("%-10d", 1))); EXPECT_STREQ("16 ", _gc(xasprintf("%-10d", 16))); EXPECT_STREQ("2147483647", _gc(xasprintf("%-10d", INT_MAX))); EXPECT_STREQ("-2147483648", _gc(xasprintf("%-10d", INT_MIN))); EXPECT_STREQ(" -123", _gc(xasprintf("%+10d", -123))); EXPECT_STREQ(" -1", _gc(xasprintf("%+10d", -1))); EXPECT_STREQ(" +1", _gc(xasprintf("%+10d", 1))); EXPECT_STREQ(" +16", _gc(xasprintf("%+10d", 16))); EXPECT_STREQ("+2147483647", _gc(xasprintf("%+10d", INT_MAX))); EXPECT_STREQ("-2147483648", _gc(xasprintf("%+10d", INT_MIN))); EXPECT_STREQ("-123", _gc(xasprintf("% d", -123))); EXPECT_STREQ("-1", _gc(xasprintf("% d", -1))); EXPECT_STREQ(" 1", _gc(xasprintf("% d", 1))); EXPECT_STREQ(" 16", _gc(xasprintf("% d", 16))); EXPECT_STREQ(" 2147483647", _gc(xasprintf("% d", INT_MAX))); EXPECT_STREQ("-2147483648", _gc(xasprintf("% d", INT_MIN))); EXPECT_STREQ("042 ", _gc(xasprintf("%-4.3d", 42))); EXPECT_STREQ("-00054", _gc(xasprintf("%-1.5lld", -54ll))); EXPECT_STREQ("00109", _gc(xasprintf("%-.5lld", 109ll))); EXPECT_STREQ("-00116", _gc(xasprintf("%-.5lld", -116ll))); EXPECT_STREQ("00108 ", _gc(xasprintf("%-8.5lld", 108ll))); EXPECT_STREQ("-00054 ", _gc(xasprintf("%-8.5lld", -54ll))); } TEST(fmt, u) { EXPECT_STREQ("042 ", _gc(xasprintf("%-4.3u", 42))); } TEST(fmt, x) { EXPECT_STREQ("0x01 ", _gc(xasprintf("%#-07.2x", 1))); EXPECT_STREQ("0x00136d ", _gc(xasprintf("%#-010.6x", 4973))); EXPECT_STREQ("0X1", _gc(xasprintf("%#X", 1))); EXPECT_STREQ("0XA", _gc(xasprintf("%#X", 10))); EXPECT_STREQ("0XFFFF", _gc(xasprintf("%#X", 65535))); EXPECT_STREQ("0XABCDEF", _gc(xasprintf("%#X", 0xABCDEF))); EXPECT_STREQ("0X1", _gc(xasprintf("%#hX", (short)1))); EXPECT_STREQ("0XA", _gc(xasprintf("%#hX", (short)10))); EXPECT_STREQ("0XFFFF", _gc(xasprintf("%#hX", (short)65535))); EXPECT_STREQ("0XABCD", _gc(xasprintf("%#hX", (short)0xABCD))); EXPECT_STREQ(" 0X308C6705", _gc(xasprintf("%#20X", 814507781))); EXPECT_STREQ("0X0000000000308C6705", _gc(xasprintf("%#020X", 814507781))); EXPECT_STREQ(" 0X6705", _gc(xasprintf("%#20hX", (short)814507781))); EXPECT_STREQ("0X000000000000006705", _gc(xasprintf("%#020hX", (short)814507781))); EXPECT_STREQ(" 0XABCDEF", _gc(xasprintf("%#20X", 0xABCDEF))); EXPECT_STREQ("0X000000000000ABCDEF", _gc(xasprintf("%#020X", 0xABCDEF))); EXPECT_STREQ(" 0XCDEF", _gc(xasprintf("%#20hX", (short)0xABCDEF))); EXPECT_STREQ("0X00000000000000CDEF", _gc(xasprintf("%#020hX", (short)0xABCDEF))); } TEST(fmt, o) { EXPECT_STREQ("0000000000000037777777634", _gc(xasprintf("%#.25o", -100))); EXPECT_STREQ("0001777777777777777777634", _gc(xasprintf("%#.25lo", -100L))); EXPECT_STREQ("0001777777777777777777634", _gc(xasprintf("%#.25llo", -100LL))); EXPECT_STREQ("0", _gc(xasprintf("%#.o", 0))); EXPECT_STREQ(" 056520", _gc(xasprintf("%#8.6o", 23888))); EXPECT_STREQ("00144 ", _gc(xasprintf("%#-8.5llo", 100ll))); EXPECT_STREQ("0 ", _gc(xasprintf("%-#02lo", 0l))); EXPECT_STREQ("0", _gc(xasprintf("%#01lo", 0l))); EXPECT_STREQ("00", _gc(xasprintf("%#02lo", 0l))); } TEST(fmt, b) { EXPECT_STREQ("000010100 ", _gc(xasprintf("%-14.9b", 20))); EXPECT_STREQ("0b110", _gc(xasprintf("%#b", 6))); } TEST(fmt, s) { EXPECT_STREQ("123456", _gc(xasprintf("%4.*s", -5, "123456"))); EXPECT_STREQ("123456789", _gc(xasprintf("%4.*s", -5, "123456789"))); EXPECT_STREQ("12345678901234567890", _gc(xasprintf("%4.*s", -5, "12345678901234567890"))); EXPECT_STREQ("123456789012345678901234567890", _gc(xasprintf("%4.*s", -5, "123456789012345678901234567890"))); EXPECT_STREQ( "1234567890123456789012345678901234567890", _gc(xasprintf("%4.*s", -5, "1234567890123456789012345678901234567890"))); EXPECT_STREQ( "12345678901234567890123456789012345678901234567890", _gc(xasprintf("%4.*s", -5, "12345678901234567890123456789012345678901234567890"))); EXPECT_STREQ( "123456789012345678901234567890123456789012345678901234567890", _gc(xasprintf( "%4.*s", -5, "123456789012345678901234567890123456789012345678901234567890"))); EXPECT_STREQ("Wide character output test", _gc(xasprintf("%S", L"Wide character output test"))); } TEST(fmt, g) { EXPECT_STREQ("1", _gc(xasprintf("%g", 1.))); EXPECT_STREQ(" 1", _gc(xasprintf("% g", 1.))); EXPECT_STREQ("+1", _gc(xasprintf("%+g", 1.))); EXPECT_STREQ("-1", _gc(xasprintf("%g", -1.))); EXPECT_STREQ("10", _gc(xasprintf("%g", 10.))); EXPECT_STREQ("-10", _gc(xasprintf("%g", -10.))); EXPECT_STREQ("1e+01", _gc(xasprintf("%.0g", 10.))); EXPECT_STREQ("-1e+01", _gc(xasprintf("%.0g", -10.))); EXPECT_STREQ("1", _gc(xasprintf("%.0g", 1.0))); EXPECT_STREQ("1e-05", _gc(xasprintf("%.0g", 0.00001))); EXPECT_STREQ("0.0001", _gc(xasprintf("%.0g", 0.0001))); EXPECT_STREQ("1e+01", _gc(xasprintf("%.1g", 10.))); EXPECT_STREQ("-1e+01", _gc(xasprintf("%.1g", -10.))); EXPECT_STREQ("1", _gc(xasprintf("%.1g", 1.0))); EXPECT_STREQ("1e-05", _gc(xasprintf("%.1g", 0.00001))); EXPECT_STREQ("0.0001", _gc(xasprintf("%.1g", 0.0001))); EXPECT_STREQ("0.007812", _gc(xasprintf("%.4g", 0.0078125))); EXPECT_STREQ("0.023438", _gc(xasprintf("%.5g", 0.0234375))); EXPECT_STREQ("1e+100", _gc(xasprintf("%g", 1e100))); EXPECT_STREQ("1e-100", _gc(xasprintf("%g", 1e-100))); EXPECT_STREQ("-1e-100", _gc(xasprintf("%g", -1e-100))); EXPECT_STREQ("0.123456", _gc(xasprintf("%g", 0.1234564))); EXPECT_STREQ("0.123457", _gc(xasprintf("%g", 0.1234566))); EXPECT_STREQ("3.14159", _gc(xasprintf("%g", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("0", _gc(xasprintf("%g", 0.))); EXPECT_STREQ("-0", _gc(xasprintf("%g", -0.))); EXPECT_STREQ("nan", _gc(xasprintf("%g", NAN))); EXPECT_STREQ("-nan", _gc(xasprintf("%g", -NAN))); EXPECT_STREQ("inf", _gc(xasprintf("%g", INFINITY))); EXPECT_STREQ("-inf", _gc(xasprintf("%g", -INFINITY))); EXPECT_STREQ("2.22507e-308", _gc(xasprintf("%g", __DBL_MIN__))); EXPECT_STREQ("1.79769e+308", _gc(xasprintf("%g", __DBL_MAX__))); EXPECT_STREQ("0", _gc(xasprintf("%G", 0.))); EXPECT_STREQ("-0", _gc(xasprintf("%G", -0.))); EXPECT_STREQ("NAN", _gc(xasprintf("%G", NAN))); EXPECT_STREQ("-NAN", _gc(xasprintf("%G", -NAN))); EXPECT_STREQ("INF", _gc(xasprintf("%G", INFINITY))); EXPECT_STREQ("-INF", _gc(xasprintf("%G", -INFINITY))); EXPECT_STREQ("2.22507E-308", _gc(xasprintf("%G", __DBL_MIN__))); EXPECT_STREQ("1.79769E+308", _gc(xasprintf("%G", __DBL_MAX__))); EXPECT_STREQ(" 0", _gc(xasprintf("%13g", 0.))); EXPECT_STREQ(" -0", _gc(xasprintf("%13g", -0.))); EXPECT_STREQ(" nan", _gc(xasprintf("%13g", NAN))); EXPECT_STREQ(" -nan", _gc(xasprintf("%13g", -NAN))); EXPECT_STREQ(" inf", _gc(xasprintf("%13g", INFINITY))); EXPECT_STREQ(" -inf", _gc(xasprintf("%13g", -INFINITY))); EXPECT_STREQ(" 2.22507e-308", _gc(xasprintf("%13g", __DBL_MIN__))); EXPECT_STREQ(" 1.79769e+308", _gc(xasprintf("%13g", __DBL_MAX__))); EXPECT_STREQ(" 0", _gc(xasprintf("%13G", 0.))); EXPECT_STREQ(" -0", _gc(xasprintf("%13G", -0.))); EXPECT_STREQ(" NAN", _gc(xasprintf("%13G", NAN))); EXPECT_STREQ(" -NAN", _gc(xasprintf("%13G", -NAN))); EXPECT_STREQ(" INF", _gc(xasprintf("%13G", INFINITY))); EXPECT_STREQ(" -INF", _gc(xasprintf("%13G", -INFINITY))); EXPECT_STREQ(" 2.22507E-308", _gc(xasprintf("%13G", __DBL_MIN__))); EXPECT_STREQ(" 1.79769E+308", _gc(xasprintf("%13G", __DBL_MAX__))); } TEST(fmt, f) { EXPECT_STREQ("3.141593", _gc(xasprintf("%f", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("3.1415926535897931", _gc(xasprintf("%.16f", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("100000000000000001590289110975991804683608085639452813" "89781327557747838772170381060813469985856815104.000000", _gc(xasprintf("%f", 1e100))); EXPECT_STREQ("0.000000", _gc(xasprintf("%f", 0.))); EXPECT_STREQ("-0.000000", _gc(xasprintf("%f", -0.))); EXPECT_STREQ("nan", _gc(xasprintf("%f", NAN))); EXPECT_STREQ("-nan", _gc(xasprintf("%f", -NAN))); EXPECT_STREQ("inf", _gc(xasprintf("%f", INFINITY))); EXPECT_STREQ("-inf", _gc(xasprintf("%f", -INFINITY))); EXPECT_STREQ("0.000000", _gc(xasprintf("%f", __DBL_MIN__))); EXPECT_STREQ( "179769313486231570814527423731704356798070567525844996598917476803157260" "780028538760589558632766878171540458953514382464234321326889464182768467" "546703537516986049910576551282076245490090389328944075868508455133942304" "583236903222948165808559332123348274797826204144723168738177180919299881" "250404026184124858368.000000", _gc(xasprintf("%f", __DBL_MAX__))); EXPECT_STREQ("0.000000", _gc(xasprintf("%F", 0.))); EXPECT_STREQ("-0.000000", _gc(xasprintf("%F", -0.))); EXPECT_STREQ("NAN", _gc(xasprintf("%F", NAN))); EXPECT_STREQ("-NAN", _gc(xasprintf("%F", -NAN))); EXPECT_STREQ("INF", _gc(xasprintf("%F", INFINITY))); EXPECT_STREQ("-INF", _gc(xasprintf("%F", -INFINITY))); EXPECT_STREQ("0.000000", _gc(xasprintf("%F", __DBL_MIN__))); EXPECT_STREQ( "179769313486231570814527423731704356798070567525844996598917476803157260" "780028538760589558632766878171540458953514382464234321326889464182768467" "546703537516986049910576551282076245490090389328944075868508455133942304" "583236903222948165808559332123348274797826204144723168738177180919299881" "250404026184124858368.000000", _gc(xasprintf("%F", __DBL_MAX__))); EXPECT_STREQ(" 0.000000", _gc(xasprintf("%10f", 0.))); EXPECT_STREQ(" -0.000000", _gc(xasprintf("%10f", -0.))); EXPECT_STREQ(" nan", _gc(xasprintf("%10f", NAN))); EXPECT_STREQ(" -nan", _gc(xasprintf("%10f", -NAN))); EXPECT_STREQ(" inf", _gc(xasprintf("%10f", INFINITY))); EXPECT_STREQ(" -inf", _gc(xasprintf("%10f", -INFINITY))); EXPECT_STREQ(" 0.000000", _gc(xasprintf("%10f", __DBL_MIN__))); EXPECT_STREQ( "179769313486231570814527423731704356798070567525844996598917476803157260" "780028538760589558632766878171540458953514382464234321326889464182768467" "546703537516986049910576551282076245490090389328944075868508455133942304" "583236903222948165808559332123348274797826204144723168738177180919299881" "250404026184124858368.000000", _gc(xasprintf("%10f", __DBL_MAX__))); EXPECT_STREQ(" 0.000000", _gc(xasprintf("%10F", 0.))); EXPECT_STREQ(" -0.000000", _gc(xasprintf("%10F", -0.))); EXPECT_STREQ(" NAN", _gc(xasprintf("%10F", NAN))); EXPECT_STREQ(" -NAN", _gc(xasprintf("%10F", -NAN))); EXPECT_STREQ(" INF", _gc(xasprintf("%10F", INFINITY))); EXPECT_STREQ(" -INF", _gc(xasprintf("%10F", -INFINITY))); EXPECT_STREQ(" 0.000000", _gc(xasprintf("%10F", __DBL_MIN__))); EXPECT_STREQ( "179769313486231570814527423731704356798070567525844996598917476803157260" "780028538760589558632766878171540458953514382464234321326889464182768467" "546703537516986049910576551282076245490090389328944075868508455133942304" "583236903222948165808559332123348274797826204144723168738177180919299881" "250404026184124858368.000000", _gc(xasprintf("%10F", __DBL_MAX__))); } TEST(fmt, e) { EXPECT_STREQ("3.14159", _gc(xasprintf("%g", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("3.141592653589793", _gc(xasprintf("%.16g", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("1.000000e+100", _gc(xasprintf("%e", 1e100))); EXPECT_STREQ("1.000000E+100", _gc(xasprintf("%E", 1e100))); EXPECT_STREQ(" 0.000000e+00", _gc(xasprintf("%24e", 0.))); EXPECT_STREQ(" -0.000000e+00", _gc(xasprintf("%24e", -0.))); EXPECT_STREQ(" nan", _gc(xasprintf("%24e", NAN))); EXPECT_STREQ(" -nan", _gc(xasprintf("%24e", -NAN))); EXPECT_STREQ(" inf", _gc(xasprintf("%24e", INFINITY))); EXPECT_STREQ(" -inf", _gc(xasprintf("%24e", -INFINITY))); EXPECT_STREQ(" 2.225074e-308", _gc(xasprintf("%24e", __DBL_MIN__))); EXPECT_STREQ(" 1.797693e+308", _gc(xasprintf("%24e", __DBL_MAX__))); EXPECT_STREQ(" 0.000000E+00", _gc(xasprintf("%24E", 0.))); EXPECT_STREQ(" -0.000000E+00", _gc(xasprintf("%24E", -0.))); EXPECT_STREQ(" NAN", _gc(xasprintf("%24E", NAN))); EXPECT_STREQ(" -NAN", _gc(xasprintf("%24E", -NAN))); EXPECT_STREQ(" INF", _gc(xasprintf("%24E", INFINITY))); EXPECT_STREQ(" -INF", _gc(xasprintf("%24E", -INFINITY))); EXPECT_STREQ(" 2.225074E-308", _gc(xasprintf("%24E", __DBL_MIN__))); EXPECT_STREQ(" 1.797693E+308", _gc(xasprintf("%24E", __DBL_MAX__))); EXPECT_STREQ(" +0.000000e+00", _gc(xasprintf("%+24e", 0.))); EXPECT_STREQ(" -0.000000e+00", _gc(xasprintf("%+24e", -0.))); EXPECT_STREQ(" +nan", _gc(xasprintf("%+24e", NAN))); EXPECT_STREQ(" -nan", _gc(xasprintf("%+24e", -NAN))); EXPECT_STREQ(" +inf", _gc(xasprintf("%+24e", INFINITY))); EXPECT_STREQ(" -inf", _gc(xasprintf("%+24e", -INFINITY))); EXPECT_STREQ(" +2.225074e-308", _gc(xasprintf("%+24e", __DBL_MIN__))); EXPECT_STREQ(" +1.797693e+308", _gc(xasprintf("%+24e", __DBL_MAX__))); EXPECT_STREQ(" +0.000000E+00", _gc(xasprintf("%+24E", 0.))); EXPECT_STREQ(" -0.000000E+00", _gc(xasprintf("%+24E", -0.))); EXPECT_STREQ(" +NAN", _gc(xasprintf("%+24E", NAN))); EXPECT_STREQ(" -NAN", _gc(xasprintf("%+24E", -NAN))); EXPECT_STREQ(" +INF", _gc(xasprintf("%+24E", INFINITY))); EXPECT_STREQ(" -INF", _gc(xasprintf("%+24E", -INFINITY))); EXPECT_STREQ(" +2.225074E-308", _gc(xasprintf("%+24E", __DBL_MIN__))); EXPECT_STREQ(" +1.797693E+308", _gc(xasprintf("%+24E", __DBL_MAX__))); } TEST(fmt, a) { EXPECT_STREQ("0x1.921fb54442d18p+1", _gc(xasprintf("%a", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ("0X1.921FB54442D18P+1", _gc(xasprintf("%A", 0x1.921fb54442d1846ap+1))); EXPECT_STREQ(" 0x0p+0", _gc(xasprintf("%24a", 0.))); EXPECT_STREQ(" -0x0p+0", _gc(xasprintf("%24a", -0.))); EXPECT_STREQ(" nan", _gc(xasprintf("%24a", NAN))); EXPECT_STREQ(" -nan", _gc(xasprintf("%24a", -NAN))); EXPECT_STREQ(" inf", _gc(xasprintf("%24a", INFINITY))); EXPECT_STREQ(" -inf", _gc(xasprintf("%24a", -INFINITY))); EXPECT_STREQ(" 0x1p-1022", _gc(xasprintf("%24a", __DBL_MIN__))); EXPECT_STREQ(" 0x1.fffffffffffffp+1023", _gc(xasprintf("%24a", __DBL_MAX__))); EXPECT_STREQ(" 0X0P+0", _gc(xasprintf("%24A", 0.))); EXPECT_STREQ(" -0X0P+0", _gc(xasprintf("%24A", -0.))); EXPECT_STREQ(" NAN", _gc(xasprintf("%24A", NAN))); EXPECT_STREQ(" -NAN", _gc(xasprintf("%24A", -NAN))); EXPECT_STREQ(" INF", _gc(xasprintf("%24A", INFINITY))); EXPECT_STREQ(" -INF", _gc(xasprintf("%24A", -INFINITY))); EXPECT_STREQ(" 0X1P-1022", _gc(xasprintf("%24A", __DBL_MIN__))); EXPECT_STREQ(" 0X1.FFFFFFFFFFFFFP+1023", _gc(xasprintf("%24A", __DBL_MAX__))); EXPECT_STREQ(" 0X1.E9A488E8A71DEP+14", _gc(xasprintf("%24A", 31337.1337))); EXPECT_STREQ(" -0X1.E9A488E8A71DEP+14", _gc(xasprintf("%24A", -31337.1337))); } TEST(fmt, p) { EXPECT_STREQ("0x1", _gc(xasprintf("%p", 1))); EXPECT_STREQ("0x10", _gc(xasprintf("%p", 16))); EXPECT_STREQ("0x31337", _gc(xasprintf("%p", 0x31337))); EXPECT_STREQ("0xffffffff", _gc(xasprintf("%p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", _gc(xasprintf("%p", 0xffff800000031337))); EXPECT_STREQ(" 0x1", _gc(xasprintf("%10p", 1))); EXPECT_STREQ(" 0x10", _gc(xasprintf("%10p", 16))); EXPECT_STREQ(" 0x31337", _gc(xasprintf("%10p", 0x31337))); EXPECT_STREQ("0xffffffff", _gc(xasprintf("%10p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", _gc(xasprintf("%10p", 0xffff800000031337))); EXPECT_STREQ("0x00000001", _gc(xasprintf("%010p", 1))); EXPECT_STREQ("0x00000010", _gc(xasprintf("%010p", 16))); EXPECT_STREQ("0x00031337", _gc(xasprintf("%010p", 0x31337))); EXPECT_STREQ("0xffffffff", _gc(xasprintf("%010p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", _gc(xasprintf("%010p", 0xffff800000031337))); EXPECT_STREQ("0x1 ", _gc(xasprintf("%-10p", 1))); EXPECT_STREQ("0x10 ", _gc(xasprintf("%-10p", 16))); EXPECT_STREQ("0x31337 ", _gc(xasprintf("%-10p", 0x31337))); EXPECT_STREQ("0xffffffff", _gc(xasprintf("%-10p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", _gc(xasprintf("%-10p", 0xffff800000031337))); EXPECT_STREQ(" 0x1", _gc(xasprintf("%+10p", 1))); EXPECT_STREQ(" 0x10", _gc(xasprintf("%+10p", 16))); EXPECT_STREQ(" 0x31337", _gc(xasprintf("%+10p", 0x31337))); EXPECT_STREQ("0xffffffff", _gc(xasprintf("%+10p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", _gc(xasprintf("%+10p", 0xffff800000031337))); EXPECT_STREQ(" 0x1", _gc(xasprintf("% 10p", 1))); EXPECT_STREQ(" 0x10", _gc(xasprintf("% 10p", 16))); EXPECT_STREQ(" 0x31337", _gc(xasprintf("% 10p", 0x31337))); EXPECT_STREQ("0xffffffff", _gc(xasprintf("% 10p", 0xffffffff))); EXPECT_STREQ("0xffff800000031337", _gc(xasprintf("% 10p", 0xffff800000031337))); } TEST(fmt, quoted) { ASSERT_STREQ(" \"hello\"", _gc(xasprintf("%`*.*s", 10, 5, "hello"))); ASSERT_STREQ("\"hello\" ", _gc(xasprintf("%-`*.*s", 10, 5, "hello"))); } TEST(fmt, nulCharacter) { char b[3] = {1, 1, 1}; ASSERT_EQ(1, snprintf(0, 0, "%c", 0)); ASSERT_EQ(1, snprintf(b, 3, "%c", 0)); ASSERT_EQ(0, b[0]); ASSERT_EQ(0, b[1]); ASSERT_EQ(1, b[2]); } TEST(fmt, regress) { char buf[512]; const char *meth = "GET"; const char *path = "/"; const char *host = "10.10.10.124"; const char *port = "8080"; const char *agent = "hurl/1.o (https://github.com/jart/cosmopolitan)"; ASSERT_EQ( strlen("GET / HTTP/1.1\r\n" "Host: 10.10.10.124:8080\r\n" "Connection: close\r\n" "User-Agent: hurl/1.o (https://github.com/jart/cosmopolitan)\r\n"), sprintf(buf, "%s %s HTTP/1.1\r\n" "Host: %s:%s\r\n" "Connection: close\r\n" "User-Agent: %s\r\n", meth, path, host, port, agent)); ASSERT_STREQ( "GET / HTTP/1.1\r\n" "Host: 10.10.10.124:8080\r\n" "Connection: close\r\n" "User-Agent: hurl/1.o (https://github.com/jart/cosmopolitan)\r\n", buf); }
22,367
413
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/sleb128_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/fmt/leb128.h" #include "libc/limits.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" char p[19]; TEST(sleb128, testZero) { EXPECT_EQ(1, sleb128(p, 0) - p); EXPECT_EQ(0, p[0]); } TEST(sleb128, testOne) { EXPECT_EQ(1, sleb128(p, 1) - p); EXPECT_EQ(1, p[0]); } TEST(sleb128, test255) { EXPECT_EQ(2, sleb128(p, 255) - p); EXPECT_EQ(255, p[0] & 255); EXPECT_EQ(1, p[1]); } TEST(sleb128, testNeg1) { EXPECT_EQ(1, sleb128(p, -1) - p); EXPECT_EQ(127, p[0]); } TEST(sleb128, testNeg255) { EXPECT_EQ(2, sleb128(p, -255) - p); EXPECT_EQ(129, p[0] & 255); EXPECT_EQ(126, p[1]); } TEST(sleb128, testMax) { EXPECT_EQ(19, sleb128(p, INT128_MAX) - p); EXPECT_EQ(255, p[0x00] & 255); EXPECT_EQ(255, p[0x01] & 255); EXPECT_EQ(255, p[0x02] & 255); EXPECT_EQ(255, p[0x03] & 255); EXPECT_EQ(255, p[0x04] & 255); EXPECT_EQ(255, p[0x05] & 255); EXPECT_EQ(255, p[0x06] & 255); EXPECT_EQ(255, p[0x07] & 255); EXPECT_EQ(255, p[0x08] & 255); EXPECT_EQ(255, p[0x09] & 255); EXPECT_EQ(255, p[0x0a] & 255); EXPECT_EQ(255, p[0x0b] & 255); EXPECT_EQ(255, p[0x0c] & 255); EXPECT_EQ(255, p[0x0d] & 255); EXPECT_EQ(255, p[0x0e] & 255); EXPECT_EQ(255, p[0x0f] & 255); EXPECT_EQ(255, p[0x10] & 255); EXPECT_EQ(255, p[0x11] & 255); EXPECT_EQ(001, p[0x12] & 255); } TEST(sleb128, testMin) { EXPECT_EQ(19, sleb128(p, INT128_MIN) - p); EXPECT_EQ(128, p[0x00] & 255); EXPECT_EQ(128, p[0x01] & 255); EXPECT_EQ(128, p[0x02] & 255); EXPECT_EQ(128, p[0x03] & 255); EXPECT_EQ(128, p[0x04] & 255); EXPECT_EQ(128, p[0x05] & 255); EXPECT_EQ(128, p[0x06] & 255); EXPECT_EQ(128, p[0x07] & 255); EXPECT_EQ(128, p[0x08] & 255); EXPECT_EQ(128, p[0x09] & 255); EXPECT_EQ(128, p[0x0a] & 255); EXPECT_EQ(128, p[0x0b] & 255); EXPECT_EQ(128, p[0x0c] & 255); EXPECT_EQ(128, p[0x0d] & 255); EXPECT_EQ(128, p[0x0e] & 255); EXPECT_EQ(128, p[0x0f] & 255); EXPECT_EQ(128, p[0x10] & 255); EXPECT_EQ(128, p[0x11] & 255); EXPECT_EQ(126, p[0x12] & 255); } BENCH(sleb128, bench) { EZBENCH2("uleb64 INT64_MAX", donothing, uleb64(p, INT64_MAX)); EZBENCH2("zleb64 INT64_MAX", donothing, zleb64(p, INT64_MAX)); EZBENCH2("sleb64 INT64_MAX", donothing, sleb64(p, INT64_MAX)); EZBENCH2("uleb128 INT64_MAX", donothing, uleb128(p, INT64_MAX)); EZBENCH2("zleb128 INT64_MAX", donothing, zleb128(p, INT64_MAX)); EZBENCH2("sleb128 INT64_MAX", donothing, sleb128(p, INT64_MAX)); EZBENCH2("zleb64 INT64_MIN", donothing, zleb64(p, INT64_MIN)); EZBENCH2("sleb64 INT64_MIN", donothing, sleb64(p, INT64_MIN)); EZBENCH2("zleb128 INT64_MIN", donothing, zleb128(p, INT64_MIN)); EZBENCH2("sleb128 INT64_MIN", donothing, sleb128(p, INT64_MIN)); }
4,584
112
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/itoa64radix16_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/itoa.h" #include "libc/testlib/testlib.h" TEST(itoa64radix16, test) { char buf[21]; EXPECT_EQ(5, uint64toarray_radix16(0x31337, buf)); EXPECT_STREQ("31337", buf); EXPECT_EQ(2, uint64toarray_radix16(0x13, buf)); EXPECT_STREQ("13", buf); EXPECT_EQ(3, uint64toarray_radix16(0x113, buf)); EXPECT_STREQ("113", buf); } TEST(itoa64fixed16, test) { char buf[21]; EXPECT_EQ(8, uint64toarray_fixed16(0x31337, buf, 32)); EXPECT_STREQ("00031337", buf); }
2,320
37
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/sscanf_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/fmt/fmt.h" #include "libc/intrin/bits.h" #include "libc/inttypes.h" #include "libc/limits.h" #include "libc/mem/mem.h" #include "libc/testlib/testlib.h" #define sscanf1(STR, FMT) \ ({ \ errno = 0; \ int128_t x = 0; \ EXPECT_EQ(1, sscanf(STR, FMT, &x)); \ x; \ }) TEST(sscanf, testMultiple) { int a, b, c; ASSERT_EQ(3, sscanf("123 123 123", "%d %x %o", &a, &b, &c)); EXPECT_EQ(123, a); EXPECT_EQ(0x123, b); EXPECT_EQ(0123, c); } TEST(sscanf, testDecimal) { EXPECT_EQ(123, sscanf1("123", "%d")); EXPECT_EQ(123, sscanf1("123", "%n")); EXPECT_EQ(123, sscanf1("123", "%u")); EXPECT_EQ((uint32_t)-123, sscanf1("-123", "%d")); } TEST(sscanf, testHex) { EXPECT_EQ(0x123, sscanf1("123", "%x")); EXPECT_EQ(0x123, sscanf1("0x123", "%x")); EXPECT_EQ(0x123, sscanf1("0123", "%x")); EXPECT_EQ(INT128_MAX, sscanf1("170141183460469231731687303715884105727", "%jjd")); EXPECT_EQ(INT128_MIN, sscanf1("-170141183460469231731687303715884105728", "%jjd")); EXPECT_EQ(UINT128_MAX, sscanf1("0xffffffffffffffffffffffffffffffff", "%jjx")); } TEST(sscanf, testOctal) { EXPECT_EQ(0123, sscanf1("123", "%o")); EXPECT_EQ(0123, sscanf1("0123", "%o")); } TEST(sscanf, testNonDirectiveCharacterMatching) { EXPECT_EQ(0, sscanf("", "")); EXPECT_EQ(0, sscanf("%", "%%")); } TEST(sscanf, testCharacter) { char c = 0; EXPECT_EQ(1, sscanf("a", "%c", &c)); EXPECT_EQ('a', c); } TEST(sscanf, testStringBuffer) { char s1[32], s2[32]; ASSERT_EQ(2, sscanf("abc xyz", "%s %s", s1, s2)); EXPECT_STREQ("abc", &s1[0]); EXPECT_STREQ("xyz", &s2[0]); } TEST(sscanf, testStringBuffer_gothicUtf8ToUtf8_roundTrips) { char s1[64], s2[64]; ASSERT_EQ(2, sscanf("𐌰𐌱𐌲𐌳 𐌴𐌵𐌶𐌷", "%63s %63s", s1, s2)); EXPECT_STREQ("𐌰𐌱𐌲𐌳", s1); EXPECT_STREQ("𐌴𐌵𐌶𐌷", s2); } TEST(sscanf, testStringBuffer_gothicUtf8to16) { char16_t s1[64], s2[64]; ASSERT_EQ(2, sscanf("𐌰𐌱𐌲𐌳 𐌴𐌵𐌶𐌷", "%63hs %63hs", s1, s2)); EXPECT_STREQ(u"𐌰𐌱𐌲𐌳", s1); EXPECT_STREQ(u"𐌴𐌵𐌶𐌷", s2); } TEST(sscanf, testStringBuffer_gothicUtf8ToUtf32) { wchar_t s1[64], s2[64]; ASSERT_EQ(2, sscanf("𐌰𐌱𐌲𐌳 𐌴𐌵𐌶𐌷", "%63ls %63ls", s1, s2)); EXPECT_STREQ(L"𐌰𐌱𐌲𐌳", s1); EXPECT_STREQ(L"𐌴𐌵𐌶𐌷", s2); } TEST(sscanf, testStringBuffer_allocatingBehavior) { char *s1, *s2; ASSERT_EQ(2, sscanf("𐌰𐌱𐌲𐌳 𐌴𐌵𐌶𐌷", "%ms %ms", &s1, &s2)); EXPECT_STREQ("𐌰𐌱𐌲𐌳", s1); EXPECT_STREQ("𐌴𐌵𐌶𐌷", s2); free(s1); free(s2); } TEST(sscanf, testPracticalBusinessApplication) { unsigned start, stop; char width; ASSERT_EQ(1, sscanf("0BF3..", "%x", &start)); EXPECT_EQ(0x0BF3, start); ASSERT_EQ(3, sscanf("0BF3..0BF8;N # So [6] TAMIL DAY SIGN", "%x..%x;%c", &start, &stop, &width)); EXPECT_EQ(0x0BF3, start); EXPECT_EQ(0x0BF8, stop); EXPECT_EQ('N', width); } TEST(sscanf, socketListenUri) { char proto[4]; unsigned char ip4[4]; uint16_t port; ASSERT_EQ(6, sscanf("tcp:127.0.0.1:31337", "%3s:%hhu.%hhu.%hhu.%hhu:%hu", proto, &ip4[0], &ip4[1], &ip4[2], &ip4[3], &port)); ASSERT_STREQ("tcp", proto); ASSERT_EQ(127, ip4[0]); ASSERT_EQ(0, ip4[1]); ASSERT_EQ(0, ip4[2]); ASSERT_EQ(1, ip4[3]); ASSERT_EQ(31337, port); } TEST(sscanf, testDiscard_notIncludedInCount) { char buf[8]; ASSERT_EQ(1, sscanf("hello there", "%*s %8s", buf)); EXPECT_STREQ("there", buf); } TEST(sscanf, testFixedWidthFormat_Integer) { int r, g, b; ASSERT_EQ(3, sscanf("#321030", "#%2x%2b%2d", &r, &g, &b)); ASSERT_EQ(0x32, r); ASSERT_EQ(2, g); ASSERT_EQ(30, b); } TEST(sscanf, testInttypes_macros) { int8_t i8 = (int8_t)0xFFFFFFFFFFFFFFFF; uint8_t u8 = (uint8_t)0xFFFFFFFFFFFFFFFF; int16_t i16 = (int16_t)0xFFFFFFFFFFFFFFFF; uint16_t u16 = (uint16_t)0xFFFFFFFFFFFFFFFF; int32_t i32 = (int32_t)0xFFFFFFFFFFFFFFFF; uint32_t u32 = (uint32_t)0xFFFFFFFFFFFFFFFF; int64_t i64 = (int64_t)0xFFFFFFFFFFFFFFFF; uint64_t u64 = (uint64_t)0xFFFFFFFFFFFFFFFF; intmax_t imax = (intmax_t)0xFFFFFFFFFFFFFFFF; uintmax_t umax = (uintmax_t)0xFFFFFFFFFFFFFFFF; int_least8_t il8 = (int_least8_t)0xFFFFFFFFFFFFFFFF; uint_least8_t ul8 = (uint_least8_t)0xFFFFFFFFFFFFFFFF; int_least16_t il16 = (int_least16_t)0xFFFFFFFFFFFFFFFF; uint_least16_t ul16 = (uint_least16_t)0xFFFFFFFFFFFFFFFF; int_least32_t il32 = (int_least32_t)0xFFFFFFFFFFFFFFFF; uint_least32_t ul32 = (uint_least32_t)0xFFFFFFFFFFFFFFFF; int_least64_t il64 = (int_least64_t)0xFFFFFFFFFFFFFFFF; uint_least64_t ul64 = (uint_least64_t)0xFFFFFFFFFFFFFFFF; int_fast8_t if8 = (int_fast8_t)0xFFFFFFFFFFFFFFFF; uint_fast8_t uf8 = (uint_fast8_t)0xFFFFFFFFFFFFFFFF; int_fast16_t if16 = (int_fast16_t)0xFFFFFFFFFFFFFFFF; uint_fast16_t uf16 = (uint_fast16_t)0xFFFFFFFFFFFFFFFF; int_fast32_t if32 = (int_fast32_t)0xFFFFFFFFFFFFFFFF; uint_fast32_t uf32 = (uint_fast32_t)0xFFFFFFFFFFFFFFFF; int_fast64_t if64 = (int_fast64_t)0xFFFFFFFFFFFFFFFF; uint_fast64_t uf64 = (uint_fast64_t)0xFFFFFFFFFFFFFFFF; ASSERT_EQ(sscanf("1", "%" SCNd8, &i8), 1); ASSERT_EQ(sscanf("1", "%" SCNu8, &u8), 1); ASSERT_EQ(sscanf("1", "%" SCNd16, &i16), 1); ASSERT_EQ(sscanf("1", "%" SCNu16, &u16), 1); ASSERT_EQ(sscanf("1", "%" SCNd32, &i32), 1); ASSERT_EQ(sscanf("1", "%" SCNu32, &u32), 1); ASSERT_EQ(sscanf("1", "%" SCNd64, &i64), 1); ASSERT_EQ(sscanf("1", "%" SCNu64, &u64), 1); ASSERT_EQ(sscanf("1", "%" SCNdMAX, &imax), 1); ASSERT_EQ(sscanf("1", "%" SCNuMAX, &umax), 1); ASSERT_EQ(sscanf("1", "%" SCNdLEAST8, &il8), 1); ASSERT_EQ(sscanf("1", "%" SCNuLEAST8, &ul8), 1); ASSERT_EQ(sscanf("1", "%" SCNdLEAST16, &il16), 1); ASSERT_EQ(sscanf("1", "%" SCNuLEAST16, &ul16), 1); ASSERT_EQ(sscanf("1", "%" SCNdLEAST32, &il32), 1); ASSERT_EQ(sscanf("1", "%" SCNuLEAST32, &ul32), 1); ASSERT_EQ(sscanf("1", "%" SCNdLEAST64, &il64), 1); ASSERT_EQ(sscanf("1", "%" SCNuLEAST64, &ul64), 1); ASSERT_EQ(sscanf("1", "%" SCNdFAST8, &if8), 1); ASSERT_EQ(sscanf("1", "%" SCNuFAST8, &uf8), 1); ASSERT_EQ(sscanf("1", "%" SCNdFAST16, &if16), 1); ASSERT_EQ(sscanf("1", "%" SCNuFAST16, &uf16), 1); ASSERT_EQ(sscanf("1", "%" SCNdFAST32, &if32), 1); ASSERT_EQ(sscanf("1", "%" SCNuFAST32, &uf32), 1); ASSERT_EQ(sscanf("1", "%" SCNdFAST64, &if64), 1); ASSERT_EQ(sscanf("1", "%" SCNuFAST64, &uf64), 1); ASSERT_EQ(i8, 1); ASSERT_EQ(u8, 1); ASSERT_EQ(i16, 1); ASSERT_EQ(u16, 1); ASSERT_EQ(i32, 1); ASSERT_EQ(u32, 1); ASSERT_EQ(i64, 1); ASSERT_EQ(u64, 1); ASSERT_EQ(imax, 1); ASSERT_EQ(umax, 1); ASSERT_EQ(il8, 1); ASSERT_EQ(ul8, 1); ASSERT_EQ(il16, 1); ASSERT_EQ(ul16, 1); ASSERT_EQ(il32, 1); ASSERT_EQ(ul32, 1); ASSERT_EQ(il64, 1); ASSERT_EQ(ul64, 1); ASSERT_EQ(if16, 1); ASSERT_EQ(uf16, 1); ASSERT_EQ(if32, 1); ASSERT_EQ(uf32, 1); ASSERT_EQ(if64, 1); ASSERT_EQ(uf64, 1); } TEST(sscanf, test0) { int v; v = 0xFFFFFFFF; ASSERT_EQ(sscanf("0", "%x", &v), 1); ASSERT_EQ(v, 0); v = 0xFFFFFFFF; ASSERT_EQ(sscanf("0", "%X", &v), 1); ASSERT_EQ(v, 0); v = 0xFFFFFFFF; ASSERT_EQ(sscanf("0", "%d", &v), 1); ASSERT_EQ(v, 0); v = 0xFFFFFFFF; ASSERT_EQ(sscanf("0", "%o", &v), 1); ASSERT_EQ(v, 0); v = 0xFFFFFFFF; ASSERT_EQ(sscanf("0", "%u", &v), 1); ASSERT_EQ(v, 0); v = 0xFFFFFFFF; ASSERT_EQ(sscanf("0", "%b", &v), 1); ASSERT_EQ(v, 0); }
9,445
262
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/sprintf_s_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/intrin/bits.h" #include "libc/intrin/safemacros.internal.h" #include "libc/mem/gc.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" #include "libc/x/xasprintf.h" static char buffer[128]; #define Format(...) _gc(xasprintf(__VA_ARGS__)) /** * @fileoverview String formatting tests. * * We use textual includes here to test UTF-8, UTF-16, and UTF-32 at the * same time, since Cosmopolitan is designed to support them all without * conditions. */ #define SUITE(NAME) NAME##s #define FORMAT(STR) STR "s" #define STRING(STR) STR #include "test/libc/fmt/sprintf_s.inc" #undef SUITE #undef FORMAT #undef STRING #define SUITE(NAME) NAME##hs #define FORMAT(STR) STR "hs" #define STRING(STR) u##STR #include "test/libc/fmt/sprintf_s.inc" #undef SUITE #undef FORMAT #undef STRING #define SUITE(NAME) NAME##ls #define FORMAT(STR) STR "ls" #define STRING(STR) L##STR #include "test/libc/fmt/sprintf_s.inc" #undef SUITE #undef FORMAT #undef STRING
2,831
62
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/strerror_r_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/fmt.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" /* * If these tests break, it's probably because * libc/sysv/consts.sh changed and * libc/sysv/kErrnoNames.S needs updating. */ TEST(strerror, e2big) { EXPECT_STARTSWITH("E2BIG", strerror(E2BIG)); } TEST(strerror, enosys) { EXPECT_STARTSWITH("ENOSYS", strerror(ENOSYS)); } TEST(strerror, einval) { EXPECT_STARTSWITH("EINVAL", strerror(EINVAL)); } TEST(strerror, symbolizingTheseNumbersAsErrorsIsHeresyInUnixStyle) { EXPECT_STARTSWITH("EUNKNOWN", strerror(0)); } TEST(strerror, enotconn_orLinkerIsntUsingLocaleC_orCodeIsOutOfSync) { EXPECT_STARTSWITH("ENOTCONN", strerror(ENOTCONN)); } TEST(strerror, exfull_orLinkerIsntUsingLocaleC_orCodeIsOutOfSync) { EXPECT_STARTSWITH("ETXTBSY", strerror(ETXTBSY)); }
2,725
55
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/uleb128_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/leb128.h" #include "libc/limits.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" char p[19]; TEST(uleb128, testZero) { EXPECT_EQ(1, uleb128(p, 0) - p); EXPECT_EQ(0, p[0]); } TEST(uleb128, testOne) { EXPECT_EQ(1, uleb128(p, 1) - p); EXPECT_EQ(1, p[0]); } TEST(uleb128, test255) { EXPECT_EQ(2, uleb128(p, 255) - p); EXPECT_EQ(255, p[0] & 255); EXPECT_EQ(1, p[1]); } TEST(uleb128, testFFFF) { EXPECT_EQ(3, uleb128(p, 0xFFFF) - p); EXPECT_EQ(255, p[0] & 255); EXPECT_EQ(255, p[1] & 255); EXPECT_EQ(3, p[2] & 255); } TEST(uleb128, testMax) { EXPECT_EQ(19, uleb128(p, UINT128_MAX) - p); EXPECT_EQ(255, p[0x00] & 255); EXPECT_EQ(255, p[0x01] & 255); EXPECT_EQ(255, p[0x02] & 255); EXPECT_EQ(255, p[0x03] & 255); EXPECT_EQ(255, p[0x04] & 255); EXPECT_EQ(255, p[0x05] & 255); EXPECT_EQ(255, p[0x06] & 255); EXPECT_EQ(255, p[0x07] & 255); EXPECT_EQ(255, p[0x08] & 255); EXPECT_EQ(255, p[0x09] & 255); EXPECT_EQ(255, p[0x0a] & 255); EXPECT_EQ(255, p[0x0b] & 255); EXPECT_EQ(255, p[0x0c] & 255); EXPECT_EQ(255, p[0x0d] & 255); EXPECT_EQ(255, p[0x0e] & 255); EXPECT_EQ(255, p[0x0f] & 255); EXPECT_EQ(255, p[0x10] & 255); EXPECT_EQ(255, p[0x11] & 255); EXPECT_EQ(003, p[0x12] & 255); }
3,113
71
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/sprintf_s.inc
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ /* MODE=tiny makes these dependencies optional */ STATIC_YOINK("strnwidth"); STATIC_YOINK("strnwidth16"); STATIC_YOINK("wcsnwidth"); TEST(SUITE(sprintf), testStringLength) { ASSERT_STREQ("This", Format(FORMAT("%.4"), STRING("This is a test"))); ASSERT_STREQ("test", Format(FORMAT("%.4"), STRING("test"))); ASSERT_STREQ("123", Format(FORMAT("%.7"), STRING("123"))); ASSERT_STREQ("", Format(FORMAT("%.7"), STRING(""))); ASSERT_STREQ("1234ab", Format(FORMAT("%.4") FORMAT("%.2"), STRING("123456"), STRING("abcdef"))); ASSERT_STREQ(FORMAT(".2"), Format(FORMAT("%.4.2"), STRING("123456"))); ASSERT_STREQ("123", Format(FORMAT("%.*"), 3, STRING("123456"))); } TEST(SUITE(sprintf), testCharacterCounting) { ASSERT_STREQ(" ♥♦♣♠☺☻▲", Format(FORMAT("%16"), STRING("♥♦♣♠☺☻▲"))); } TEST(SUITE(snprintf), testTableFlip) { EXPECT_STREQ("Table flip ", Format("%-20ls", L"Table flip")); EXPECT_STREQ("(╯°□°)╯︵L┻━┻ ", Format("%-20ls", L"(╯°□°)╯︵L┻━┻")); EXPECT_STREQ("(╯°□°)╯︵u┻━┻ ", Format("%-20hs", u"(╯°□°)╯︵u┻━┻")); EXPECT_STREQ("ちゃぶ台返し ", Format("%-20ls", L"ちゃぶ台返し")); EXPECT_STREQ(" (╯°□°)╯︵L┻━┻", Format("%20ls", L"(╯°□°)╯︵L┻━┻")); EXPECT_STREQ(" ちゃぶ台返し", Format("%20ls", L"ちゃぶ台返し")); } TEST(SUITE(snprintf), testCombiningWidth) { EXPECT_STREQ("H̲E̲L̲L̲O̲ ", Format("%-10ls", L"H\u0332E\u0332L\u0332L\u0332O\u0332")); EXPECT_STREQ(" H̲E̲L̲L̲O̲", Format("%10hs", u"H\u0332E\u0332L\u0332L\u0332O\u0332")); } TEST(SUITE(snprintf), testQuoting) { EXPECT_STREQ("\\\"hi┻\\'━┻", Format("%'s", "\"hi┻'━┻")); EXPECT_STREQ(STRINGIFY("\"hi┻\'━┻"), Format("%`'s", "\"hi┻'━┻")); EXPECT_STREQ(STRINGIFY("\177\"hi┻\'━┻"), Format("%`'s", "\x7f\"hi┻'━┻")); } TEST(SUITE(snprintf), testBing_cString_stopsAtNulTerminator) { EXPECT_STREQ("♥♦♣♠", Format("%#s", "\3\4\5\6\0\3\4\5\6")); } TEST(SUITE(snprintf), testBing_precisionString_showsTrueBinary) { EXPECT_STREQ("♥♦♣♠ ♥♦♣♠", Format("%#.*s", 9, "\3\4\5\6\0\3\4\5\6")); } TEST(SUITE(snprintf), testStringPrecision_showsTrueBinary) { EXPECT_STREQ("\3\4\0", Format("%.*s", 3, "\3\4\0")); } TEST(SUITE(snprintf), testPrecision_usesByteCount) { EXPECT_STREQ("ちゃ", Format("%.*s", 6, "ちゃぶ台返し")); } TEST(SUITE(snprintf), testReprChar16) { EXPECT_STREQ("u'♥'", Format("%`'hc", u'♥')); } TEST(SUITE(snprintf), testReprChar32) { EXPECT_STREQ("L'♥'", Format("%`'lc", L'♥')); } TEST(SUITE(snprintf), testReprUtf8) { EXPECT_STREQ("\"♥\"", Format("%`'s", u8"♥")); } TEST(SUITE(snprintf), testReprUtf8Precision_countsBytes) { EXPECT_STREQ("\"♥\"", Format("%`'.*s", 3, u8"♥")); }
4,782
93
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/formathex64_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" char buf[19]; void SetUp(void) { memset(buf, 0x55, sizeof(buf)); } TEST(FormatHex64, test1) { EXPECT_EQ(1, FormatHex64(buf, 0, 2) - buf); EXPECT_STREQ("0", buf); } TEST(FormatHex64, test2) { EXPECT_EQ(1, FormatHex64(buf, 0, 0) - buf); EXPECT_STREQ("0", buf); EXPECT_EQ(3, FormatHex64(buf, 0, 1) - buf); EXPECT_STREQ("0x0", buf); } TEST(FormatHex64, test3) { EXPECT_EQ(4, FormatHex64(buf, 1, 2) - buf); EXPECT_STREQ("0x01", buf); } TEST(FormatHex64, test4) { EXPECT_EQ(1, FormatHex64(buf, 1, 0) - buf); EXPECT_STREQ("1", buf); } TEST(FormatHex64, test5) { EXPECT_EQ(18, FormatHex64(buf, 01777777777777777777777UL, 2) - buf); EXPECT_STREQ("0xffffffffffffffff", buf); } TEST(FormatHex64, test6) { EXPECT_EQ(16, FormatHex64(buf, 01777777777777777777777UL, 0) - buf); EXPECT_STREQ("ffffffffffffffff", buf); } TEST(FormatHex64, test7) { EXPECT_EQ(18, FormatHex64(buf, 0xEBF2AA499B9028EAul, 2) - buf); EXPECT_STREQ("0xebf2aa499b9028ea", buf); } TEST(FormatHex64, test8) { EXPECT_EQ(18, FormatHex64(buf, 0x00F2AA499B9028EAul, 2) - buf); EXPECT_STREQ("0x00f2aa499b9028ea", buf); } TEST(FormatHex64, testScalesToWordSizes) { EXPECT_EQ(2 + 2, FormatHex64(buf, 13, 2) - buf); EXPECT_STREQ("0x0d", buf); EXPECT_EQ(4 + 2, FormatHex64(buf, 31337, 2) - buf); EXPECT_STREQ("0x7a69", buf); EXPECT_EQ(8 + 2, FormatHex64(buf, 65536, 2) - buf); EXPECT_STREQ("0x00010000", buf); } BENCH(FormatHex64, bench) { EZBENCH2("FormatUint64 tiny", donothing, FormatUint64(buf, 1)); EZBENCH2("FormatOctal64 tiny", donothing, FormatOctal64(buf, 1, true)); EZBENCH2("FormatHex64 tiny", donothing, FormatHex64(buf, 1, 2)); EZBENCH2("FormatHex64 big", donothing, FormatHex64(buf, 01777777777777777777777UL, 2)); }
3,742
89
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/timevaltofiletime_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/timeval.h" #include "libc/fmt/conv.h" #include "libc/nt/struct/filetime.h" #include "libc/testlib/testlib.h" #include "libc/time/time.h" TEST(TimeValToFileTime, roundTrip) { struct timeval tv1, tv2; tv1.tv_sec = 31337; tv1.tv_usec = 1337; tv2 = FileTimeToTimeVal(TimeValToFileTime(tv1)); EXPECT_EQ(31337, tv2.tv_sec); EXPECT_EQ(1337, tv2.tv_usec); } TEST(TimeSpecToFileTime, roundTrip_withSomeTruncation) { struct timespec tv1, tv2; tv1.tv_sec = 31337; tv1.tv_nsec = 1337; tv2 = FileTimeToTimeSpec(TimeSpecToFileTime(tv1)); EXPECT_EQ(31337, tv2.tv_sec); EXPECT_EQ(1300, tv2.tv_nsec); }
2,476
42
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/test.mk
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ #───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ PKGS += TEST_LIBC_FMT TEST_LIBC_FMT_SRCS := $(wildcard test/libc/fmt/*.c) TEST_LIBC_FMT_SRCS_TEST = $(filter %_test.c,$(TEST_LIBC_FMT_SRCS)) TEST_LIBC_FMT_BINS = $(TEST_LIBC_FMT_COMS) $(TEST_LIBC_FMT_COMS:%=%.dbg) TEST_LIBC_FMT_TESTS = $(TEST_LIBC_FMT_SRCS_TEST:%.c=o/$(MODE)/%.com.ok) TEST_LIBC_FMT_OBJS = \ $(TEST_LIBC_FMT_SRCS:%.c=o/$(MODE)/%.o) TEST_LIBC_FMT_COMS = \ $(TEST_LIBC_FMT_SRCS:%.c=o/$(MODE)/%.com) TEST_LIBC_FMT_CHECKS = \ $(TEST_LIBC_FMT_SRCS_TEST:%.c=o/$(MODE)/%.com.runs) TEST_LIBC_FMT_DIRECTDEPS = \ LIBC_FMT \ LIBC_INTRIN \ LIBC_LOG \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ LIBC_STDIO \ LIBC_STR \ LIBC_STUBS \ LIBC_SYSV \ LIBC_TESTLIB \ LIBC_TINYMATH \ LIBC_X \ THIRD_PARTY_GDTOA TEST_LIBC_FMT_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_FMT_DIRECTDEPS),$($(x)))) o/$(MODE)/test/libc/fmt/fmt.pkg: \ $(TEST_LIBC_FMT_OBJS) \ $(foreach x,$(TEST_LIBC_FMT_DIRECTDEPS),$($(x)_A).pkg) o/$(MODE)/test/libc/fmt/%.com.dbg: \ $(TEST_LIBC_FMT_DEPS) \ o/$(MODE)/test/libc/fmt/%.o \ o/$(MODE)/test/libc/fmt/fmt.pkg \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) $(TEST_LIBC_FMT_OBJS): test/libc/fmt/test.mk $(TEST_LIBC_FMT_OBJS): private \ DEFAULT_CCFLAGS += \ -fno-builtin o/$(MODE)/test/libc/fmt/fprintf_test.com.runs: \ private .UNVEIL += w:/dev/full .PHONY: o/$(MODE)/test/libc/fmt o/$(MODE)/test/libc/fmt: \ $(TEST_LIBC_FMT_BINS) \ $(TEST_LIBC_FMT_CHECKS)
1,748
65
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/stripexts_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" #include "libc/mem/gc.internal.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" TEST(stripexts, test) { char s[] = "foo/bar.com.dbg"; EXPECT_STREQ("foo/bar", stripexts(s)); } TEST(stripexts, test2) { char s[] = "foo/bar.com.dbg"; EXPECT_STREQ("bar", stripexts(basename(s))); } TEST(xstripexts, test) { EXPECT_STREQ("foo/bar", gc(xstripexts("foo/bar.com.dbg"))); } TEST(xstripexts, test2) { EXPECT_STREQ("bar", gc(xstripexts(basename("foo/bar.com.dbg")))); }
2,373
42
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/snprintf_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2023 Gabriel Ravier │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" TEST(snprintf, testVeryLargePrecision) { char buf[512] = {}; int i = snprintf(buf, sizeof(buf), "%.9999u", 10); ASSERT_EQ(i, 9999); ASSERT_EQ(strlen(buf), 511); }
2,095
30
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/printf_uppercase_f_static_yoink_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2023 Gabriel Ravier │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/intrin/kprintf.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" // We specifically avoid the test framework because otherwise __fmt_dtoa is // always automatically pulled in from code in there - and this is what we're // testing for here int main() { char buffer[30]; int snprintf_result = snprintf(buffer, sizeof(buffer), "%F", .0); if (strcmp(buffer, "0.000000")) { kprintf("error: snprintf gave us '%s' instead of the expected '0.000000'\n", buffer); abort(); } if (snprintf_result != 8) { kprintf("error: snprintf returned %d instead of 8\n", snprintf_result); abort(); } }
2,512
42
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/dirname_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" #include "libc/log/log.h" #include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" #include "libc/testlib/testlib.h" TEST(dirname, test) { EXPECT_STREQ("/usr/lib", dirname(gc(strdup("/usr/lib/foo.bar")))); EXPECT_STREQ("/usr", dirname(gc(strdup("/usr/lib")))); EXPECT_STREQ("usr", dirname(gc(strdup("usr/lib")))); EXPECT_STREQ("/", dirname(gc(strdup("/usr/")))); EXPECT_STREQ(".", dirname(gc(strdup("usr")))); EXPECT_STREQ("/", dirname(gc(strdup("/")))); EXPECT_STREQ(".", dirname(gc(strdup(".")))); EXPECT_STREQ(".", dirname(gc(strdup("..")))); EXPECT_STREQ(".", dirname(gc(strdup("")))); }
2,503
37
jart/cosmopolitan
false
cosmopolitan/test/libc/fmt/atoi_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/limits.h" #include "libc/stdio/stdio.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" void __on_arithmetic_overflow(void) { // prevent -ftrapv crashes // // for some reason gcc generates trap code even when we're doing it // manually with __builtin_mul_overflow() :'( } TEST(atoi, test) { EXPECT_EQ(0, atoi("")); EXPECT_EQ(0, atoi("-b")); EXPECT_EQ(0, atoi("0")); EXPECT_EQ(1, atoi("1")); EXPECT_EQ(9, atoi("9")); EXPECT_EQ(12, atoi("12")); EXPECT_EQ(-12, atoi("-12")); EXPECT_EQ(31337, atoi("31337")); EXPECT_EQ(+0, atoi("+0")); EXPECT_EQ(+1, atoi("+1")); EXPECT_EQ(+9, atoi("+9")); EXPECT_EQ(-0, atoi("-0")); EXPECT_EQ(-1, atoi("-1")); EXPECT_EQ(-9, atoi("-9")); EXPECT_EQ(-31337, atoi("-31337")); EXPECT_EQ(INT_MIN, atoi("-2147483648")); EXPECT_EQ(INT_MAX, atoi("2147483647")); EXPECT_EQ(INT_MIN, atoi("-2147483649")); EXPECT_EQ(INT_MAX, atoi("2147483648")); EXPECT_EQ(INT_MIN, atoi("-2147483658")); EXPECT_EQ(INT_MAX, atoi("2147483657")); EXPECT_EQ(123, atoi(" 123")); EXPECT_EQ(123, atoi(" \t123")); EXPECT_EQ(+123, atoi(" +123")); EXPECT_EQ(+123, atoi(" \t+123")); EXPECT_EQ(-123, atoi(" -123")); EXPECT_EQ(-123, atoi(" \t-123")); EXPECT_EQ(0, atoi(" a123")); EXPECT_EQ(0, atoi(" \ta123")); } TEST(atoi, testWithinLimit_doesntChangeErrno) { errno = 7; EXPECT_EQ(INT_MAX, atoi("2147483647")); EXPECT_EQ(7, errno); errno = 7; EXPECT_EQ(INT_MIN, atoi("-2147483648")); EXPECT_EQ(7, errno); } TEST(atoi, testOutsideLimit_saturatesAndSetsErangeErrno) { errno = 0; EXPECT_EQ(INT_MAX, atoi("2147483648")); EXPECT_EQ(ERANGE, errno); errno = 0; EXPECT_EQ(INT_MIN, atoi("-2147483649")); EXPECT_EQ(ERANGE, errno); } TEST(atol, test) { EXPECT_EQ(0, atol("")); EXPECT_EQ(0, atol("0")); EXPECT_EQ(1, atol("1")); EXPECT_EQ(9, atol("9")); EXPECT_EQ(12, atol("12")); EXPECT_EQ(-12, atol("-12")); EXPECT_EQ(31337, atol("31337")); EXPECT_EQ(+0, atol("+0")); EXPECT_EQ(+1, atol("+1")); EXPECT_EQ(+9, atol("+9")); EXPECT_EQ(-0, atol("-0")); EXPECT_EQ(-1, atol("-1")); EXPECT_EQ(-9, atol("-9")); EXPECT_EQ(-31337, atol("-31337")); EXPECT_EQ(LONG_MIN, atol("-9223372036854775808")); EXPECT_EQ(LONG_MAX, atol("9223372036854775807")); EXPECT_EQ(LONG_MIN, atol("-9223372036854775809")); EXPECT_EQ(LONG_MAX, atol("9223372036854775808")); EXPECT_EQ(LONG_MIN, atol("-9223372036854775818")); EXPECT_EQ(LONG_MAX, atol("9223372036854775817")); EXPECT_EQ(123, atol(" 123")); EXPECT_EQ(123, atol(" \t123")); EXPECT_EQ(-123, atol(" -123")); EXPECT_EQ(-123, atol(" \t-123")); EXPECT_EQ(0, atol(" a123")); EXPECT_EQ(0, atol(" \ta123")); } TEST(strtol, test) { EXPECT_EQ(0, strtol("", 0, 10)); EXPECT_EQ(0, strtol("0", 0, 10)); EXPECT_EQ(1, strtol("1", 0, 10)); EXPECT_EQ(9, strtol("9", 0, 10)); EXPECT_EQ(12, strtol("12", 0, 10)); EXPECT_EQ(-12, strtol("-12", 0, 10)); EXPECT_EQ(31337, strtol("31337", 0, 10)); EXPECT_EQ(0, strtol("-0", 0, 10)); EXPECT_EQ(-1, strtol("-1", 0, 10)); EXPECT_EQ(-9, strtol("-9", 0, 10)); EXPECT_EQ(-31337, strtol("-31337", 0, 10)); EXPECT_EQ(LONG_MIN, strtol("-9223372036854775808", 0, 10)); EXPECT_EQ(LONG_MAX, strtol("9223372036854775807", 0, 10)); EXPECT_EQ(LONG_MIN, strtol("-9223372036854775809", 0, 10)); EXPECT_EQ(LONG_MAX, strtol("9223372036854775808", 0, 10)); EXPECT_EQ(LONG_MIN, strtol("-9223372036854775818", 0, 10)); EXPECT_EQ(LONG_MAX, strtol("9223372036854775817", 0, 10)); EXPECT_EQ(123, strtol(" 123", 0, 10)); EXPECT_EQ(123, strtol(" \t123", 0, 10)); EXPECT_EQ(-123, strtol(" -123", 0, 10)); EXPECT_EQ(-123, strtol(" \t-123", 0, 10)); EXPECT_EQ(0, strtol(" a123", 0, 10)); EXPECT_EQ(0, strtol(" \ta123", 0, 10)); } TEST(strtol, testBinary) { char *e; ASSERT_EQ(85, strtol("0b1010101", 0, 2)); ASSERT_EQ(85, strtol("0b1010101", 0, 0)); ASSERT_EQ(85, strtol("0b1010101", &e, 0)); ASSERT_EQ(0, *e); } TEST(strtol, testOutsideLimit) { errno = 0; EXPECT_EQ(0x7fffffffffffffff, strtol("0x8000000000000000", NULL, 0)); EXPECT_EQ(ERANGE, errno); errno = 0; EXPECT_EQ(0x8000000000000000, strtol("-0x8000000000000001", NULL, 0)); EXPECT_EQ(ERANGE, errno); errno = 0; EXPECT_EQ(0x8000000000000001, strtol("-9223372036854775807", NULL, 0)); EXPECT_EQ(0, errno); errno = 0; EXPECT_EQ(0x8000000000000000, strtol("-9223372036854775808", NULL, 0)); EXPECT_EQ(0, errno); } TEST(strtoul, ipAddress) { char *e; const char *p = "1.2.3.4"; EXPECT_EQ(1, strtoul(p, &e, 0)); EXPECT_EQ(1, e - p); } TEST(strtoul, weirdComma) { char *e; const char *p = ",2"; EXPECT_EQ(0, strtoul(p, &e, 0)); EXPECT_EQ(0, e - p); } TEST(strtol, testHex) { EXPECT_EQ(0, strtol("", 0, 16)); EXPECT_EQ(0, strtol("0", 0, 16)); EXPECT_EQ(1, strtol("1", 0, 16)); EXPECT_EQ(9, strtol("9", 0, 16)); EXPECT_EQ(18, strtol("12", 0, 16)); EXPECT_EQ(-18, strtol("-12", 0, 16)); EXPECT_EQ(201527, strtol("31337", 0, 16)); EXPECT_EQ(15, strtol("f", 0, 16)); EXPECT_EQ(3735928559, strtol("deadbeef", 0, 16)); EXPECT_EQ(0, strtol("-0", 0, 16)); EXPECT_EQ(-1, strtol("-1", 0, 16)); EXPECT_EQ(-9, strtol("-9", 0, 16)); EXPECT_EQ(-201527, strtol("-31337", 0, 16)); EXPECT_EQ(-3735928559, strtol("-DEADBEEF", 0, 16)); EXPECT_EQ(LONG_MIN, strtol("-8000000000000000", 0, 16)); EXPECT_EQ(LONG_MAX, strtol("7fffffffffffffff", 0, 16)); EXPECT_EQ(LONG_MIN, strtol("-8000000000000001", 0, 16)); EXPECT_EQ(LONG_MAX, strtol("8000000000000000", 0, 16)); EXPECT_EQ(LONG_MIN, strtol("-0x8000000000000000", 0, 16)); EXPECT_EQ(LONG_MAX, strtol("0x7fffffffffffffff", 0, 16)); EXPECT_EQ(LONG_MIN, strtol("-0x800000000000000a", 0, 16)); EXPECT_EQ(LONG_MAX, strtol("0x8000000000000009", 0, 16)); EXPECT_EQ(291, strtol(" 123", 0, 16)); EXPECT_EQ(291, strtol(" \t123", 0, 16)); EXPECT_EQ(-291, strtol(" -123", 0, 16)); EXPECT_EQ(-291, strtol(" \t-123", 0, 16)); EXPECT_EQ(0, strtol(" z123", 0, 16)); EXPECT_EQ(0, strtol(" \tz123", 0, 16)); } TEST(strtol, testOctal) { EXPECT_EQ(0, strtol("", 0, 8)); EXPECT_EQ(0, strtol("0", 0, 8)); EXPECT_EQ(1, strtol("1", 0, 8)); EXPECT_EQ(7, strtol("7", 0, 8)); EXPECT_EQ(10, strtol("12", 0, 8)); EXPECT_EQ(-10, strtol("-12", 0, 8)); EXPECT_EQ(13023, strtol("31337", 0, 8)); EXPECT_EQ(0, strtol("-0", 0, 8)); EXPECT_EQ(-1, strtol("-1", 0, 8)); EXPECT_EQ(-7, strtol("-7", 0, 8)); EXPECT_EQ(-13023, strtol("-31337", 0, 8)); EXPECT_EQ(LONG_MIN, strtol("-1000000000000000000000", 0, 8)); EXPECT_EQ(LONG_MAX, strtol("777777777777777777777", 0, 8)); EXPECT_EQ(LONG_MIN, strtol("-01000000000000000000000", 0, 0)); EXPECT_EQ(LONG_MAX, strtol("0777777777777777777777", 0, 0)); EXPECT_EQ(1152921504606846975, strtol("077777777777777777777", 0, 0)); EXPECT_EQ(-144115188075855872, strtol("-010000000000000000000", 0, 0)); } TEST(strtol, testBase36) { EXPECT_EQ(35, strtol("z", 0, 36)); EXPECT_EQ(5089507, strtol("31337", 0, 36)); EXPECT_EQ(29234652, strtol("hello", 0, 36)); EXPECT_EQ(29234652, strtol("HELLO", 0, 36)); } TEST(strtol, testEndPtr) { char *e; const char *p; p = "1"; ASSERT_EQ(1, strtol(p, &e, 2)); ASSERT_EQ(1, e - p); p = ""; ASSERT_EQ(0, strtol(p, &e, 2)); ASSERT_EQ(0, e - p); } TEST(wcstol, testEndPtr) { wchar_t *e; const wchar_t *p; p = L"1"; ASSERT_EQ(1, wcstol(p, &e, 2)); ASSERT_EQ(1, e - p); p = L""; ASSERT_EQ(0, wcstol(p, &e, 2)); ASSERT_EQ(0, e - p); } TEST(strtoul, testEndPtr) { char *e; const char *p; p = "1"; ASSERT_EQ(1, strtoul(p, &e, 2)); ASSERT_EQ(1, e - p); p = ""; ASSERT_EQ(0, strtoul(p, &e, 2)); ASSERT_EQ(0, e - p); } TEST(wcstoul, testEndPtr) { wchar_t *e; const wchar_t *p; p = L"1"; ASSERT_EQ(1, wcstoul(p, &e, 2)); ASSERT_EQ(1, e - p); p = L""; ASSERT_EQ(0, wcstoul(p, &e, 2)); ASSERT_EQ(0, e - p); } TEST(strtoimax, testZero) { EXPECT_EQ(0, strtoimax("0", NULL, 0)); } TEST(strtoimax, testDecimal) { EXPECT_EQ(-123, strtoimax("-123", NULL, 0)); } TEST(strtoimax, testHex) { EXPECT_EQ(-255, strtoimax("-0xff", NULL, 0)); EXPECT_EQ(255, strtoimax("0xff", NULL, 16)); } TEST(strtoimax, testOctal) { EXPECT_EQ(-123, strtoimax("-0173", NULL, 0)); EXPECT_EQ(123, strtoimax("0173", NULL, 8)); } TEST(strtoimax, testBinary) { EXPECT_EQ(-42, strtoimax("-0b101010", NULL, 0)); EXPECT_EQ(42, strtoimax("0b101010", NULL, 2)); ASSERT_EQ(85, strtoimax("0b1010101", 0, 2)); ASSERT_EQ(85, strtoimax("0b1010101", 0, 0)); } TEST(strtoimax, testEndPtr) { char *e; const char *p = "1"; ASSERT_EQ(1, strtoimax(p, &e, 2)); ASSERT_EQ(1, e - p); } TEST(strtoi128, testLimits) { EXPECT_EQ( ((uint128_t)0xffffffffffffffff) << 64 | (uint128_t)0xffffffffffffffff, strtoi128("-1", NULL, 0)); EXPECT_EQ( ((uint128_t)0x7fffffffffffffff) << 64 | (uint128_t)0xffffffffffffffff, strtoi128("0x7fffffffffffffffffffffffffffffff", NULL, 0)); } TEST(strtoi128, testOutsideLimit) { errno = 0; EXPECT_EQ( ((uint128_t)0x7fffffffffffffff) << 64 | (uint128_t)0xffffffffffffffff, strtoi128("0x80000000000000000000000000000000", NULL, 0)); EXPECT_EQ(ERANGE, errno); errno = 0; EXPECT_EQ(((uint128_t)0x8000000000000000) << 64 | 0x0000000000000000, strtoi128("-0x80000000000000000000000000000001", NULL, 0)); EXPECT_EQ(ERANGE, errno); } TEST(strtoul, neghex) { errno = 0; ASSERT_EQ(-16, (long)strtoul("0xfffffffffffffff0", NULL, 0)); EXPECT_EQ(0, errno); } TEST(strtoumax, testZero) { EXPECT_EQ(UINTMAX_MIN, strtoumax("0", NULL, 0)); EXPECT_EQ(UINT128_MIN, strtou128("0", NULL, 0)); } TEST(strtoumax, testDecimal) { EXPECT_EQ(123, strtoumax("123", NULL, 0)); EXPECT_EQ(-123, strtoumax("-123", NULL, 0)); } TEST(strtoumax, testHex) { EXPECT_EQ(255, strtoumax("0xff", NULL, 0)); EXPECT_EQ(255, strtoumax("0xff", NULL, 16)); } TEST(strtoumax, testOctal) { EXPECT_EQ(123, strtoumax("0173", NULL, 0)); EXPECT_EQ(123, strtoumax("0173", NULL, 8)); } TEST(strtoumax, testBinary) { EXPECT_EQ(42, strtoumax("0b101010", NULL, 0)); EXPECT_EQ(42, strtoumax("0b101010", NULL, 2)); } TEST(strtou128, test128imum) { EXPECT_EQ(UINT128_MAX, strtou128("340282366920938463463374607431768211455", NULL, 0)); EXPECT_EQ(UINT128_MAX, strtou128("0xffffffffffffffffffffffffffffffff", NULL, 0)); } TEST(strtou128, testTwosBane) { EXPECT_EQ(((uint128_t)0x8000000000000000) << 64 | 0x0000000000000000, strtou128("0x80000000000000000000000000000000", NULL, 0)); } TEST(wcstol, test) { EXPECT_EQ(0, wcstol(L"", 0, 10)); EXPECT_EQ(0, wcstol(L"0", 0, 10)); EXPECT_EQ(1, wcstol(L"1", 0, 10)); EXPECT_EQ(9, wcstol(L"9", 0, 10)); EXPECT_EQ(12, wcstol(L"12", 0, 10)); EXPECT_EQ(-12, wcstol(L"-12", 0, 10)); EXPECT_EQ(31337, wcstol(L"31337", 0, 10)); EXPECT_EQ(0, wcstol(L"-0", 0, 10)); EXPECT_EQ(-1, wcstol(L"-1", 0, 10)); EXPECT_EQ(-9, wcstol(L"-9", 0, 10)); EXPECT_EQ(-31337, wcstol(L"-31337", 0, 10)); EXPECT_EQ(LONG_MIN, wcstol(L"-9223372036854775808", 0, 10)); EXPECT_EQ(LONG_MAX, wcstol(L"9223372036854775807", 0, 10)); EXPECT_EQ(LONG_MIN, wcstol(L"-9223372036854775809", 0, 10)); EXPECT_EQ(LONG_MAX, wcstol(L"9223372036854775808", 0, 10)); EXPECT_EQ(LONG_MIN, wcstol(L"-9223372036854775818", 0, 10)); EXPECT_EQ(LONG_MAX, wcstol(L"9223372036854775817", 0, 10)); EXPECT_EQ(123, wcstol(L" 123", 0, 10)); EXPECT_EQ(123, wcstol(L" \t123", 0, 10)); EXPECT_EQ(-123, wcstol(L" -123", 0, 10)); EXPECT_EQ(-123, wcstol(L" \t-123", 0, 10)); EXPECT_EQ(0, wcstol(L" a123", 0, 10)); EXPECT_EQ(0, wcstol(L" \ta123", 0, 10)); } TEST(wcstol, testOutsideLimit) { errno = 0; EXPECT_EQ(0x7fffffffffffffff, wcstol(L"0x8000000000000000", NULL, 0)); EXPECT_EQ(ERANGE, errno); errno = 0; EXPECT_EQ(0x8000000000000000, wcstol(L"-0x8000000000000001", NULL, 0)); EXPECT_EQ(ERANGE, errno); errno = 0; EXPECT_EQ(0x8000000000000001, wcstol(L"-9223372036854775807", NULL, 0)); EXPECT_EQ(0, errno); errno = 0; EXPECT_EQ(0x8000000000000000, wcstol(L"-9223372036854775808", NULL, 0)); EXPECT_EQ(0, errno); } TEST(wcstol, testHex) { EXPECT_EQ(0, wcstol(L"", 0, 16)); EXPECT_EQ(0, wcstol(L"0", 0, 16)); EXPECT_EQ(1, wcstol(L"1", 0, 16)); EXPECT_EQ(9, wcstol(L"9", 0, 16)); EXPECT_EQ(18, wcstol(L"12", 0, 16)); EXPECT_EQ(-18, wcstol(L"-12", 0, 16)); EXPECT_EQ(201527, wcstol(L"31337", 0, 16)); EXPECT_EQ(15, wcstol(L"f", 0, 16)); EXPECT_EQ(3735928559, wcstol(L"deadbeef", 0, 16)); EXPECT_EQ(0, wcstol(L"-0", 0, 16)); EXPECT_EQ(-1, wcstol(L"-1", 0, 16)); EXPECT_EQ(-9, wcstol(L"-9", 0, 16)); EXPECT_EQ(-201527, wcstol(L"-31337", 0, 16)); EXPECT_EQ(-3735928559, wcstol(L"-DEADBEEF", 0, 16)); EXPECT_EQ(LONG_MIN, wcstol(L"-8000000000000000", 0, 16)); EXPECT_EQ(LONG_MAX, wcstol(L"7fffffffffffffff", 0, 16)); EXPECT_EQ(LONG_MIN, wcstol(L"-8000000000000001", 0, 16)); EXPECT_EQ(LONG_MAX, wcstol(L"8000000000000000", 0, 16)); EXPECT_EQ(LONG_MIN, wcstol(L"-0x8000000000000000", 0, 16)); EXPECT_EQ(LONG_MAX, wcstol(L"0x7fffffffffffffff", 0, 16)); EXPECT_EQ(LONG_MIN, wcstol(L"-0x800000000000000a", 0, 16)); EXPECT_EQ(LONG_MAX, wcstol(L"0x8000000000000009", 0, 16)); EXPECT_EQ(291, wcstol(L" 123", 0, 16)); EXPECT_EQ(291, wcstol(L" \t123", 0, 16)); EXPECT_EQ(-291, wcstol(L" -123", 0, 16)); EXPECT_EQ(-291, wcstol(L" \t-123", 0, 16)); EXPECT_EQ(0, wcstol(L" z123", 0, 16)); EXPECT_EQ(0, wcstol(L" \tz123", 0, 16)); } TEST(wcstol, testBase36) { EXPECT_EQ(35, wcstol(L"z", 0, 36)); EXPECT_EQ(5089507, wcstol(L"31337", 0, 36)); EXPECT_EQ(29234652, wcstol(L"hello", 0, 36)); EXPECT_EQ(29234652, wcstol(L"HELLO", 0, 36)); } TEST(strtol, testWormsMeat) { ASSERT_EQ(0x4e00, strtol("0x4e00", 0, 0)); } TEST(strtol, testIBM) { char *e; ASSERT_EQ(1, strtol("1e-", &e, 10)); ASSERT_STREQ("e-", e); ASSERT_EQ(0, strtol("-", &e, 10)); ASSERT_STREQ("-", e); ASSERT_EQ(0, strtol("0f", &e, 10)); ASSERT_STREQ("f", e); } TEST(strtoul, testIBM) { char *e; ASSERT_EQ(1, strtoul("1e-", &e, 10)); ASSERT_STREQ("e-", e); ASSERT_EQ(0, strtoul("-", &e, 10)); ASSERT_STREQ("-", e); ASSERT_EQ(0, strtoul("0f", &e, 10)); ASSERT_STREQ("f", e); } TEST(strtoll, testIBM) { char *e; ASSERT_EQ(1, strtoll("1e-", &e, 10)); ASSERT_STREQ("e-", e); ASSERT_EQ(0, strtoll("-", &e, 10)); ASSERT_STREQ("-", e); ASSERT_EQ(0, strtoll("0f", &e, 10)); ASSERT_STREQ("f", e); } TEST(strtoull, testIBM) { char *e; ASSERT_EQ(1, strtoull("1e-", &e, 10)); ASSERT_STREQ("e-", e); ASSERT_EQ(0, strtoull("-", &e, 10)); ASSERT_STREQ("-", e); ASSERT_EQ(0, strtoull("0f", &e, 10)); ASSERT_STREQ("f", e); } TEST(strtoimax, testIBM) { char *e; ASSERT_EQ(1, strtoimax("1e-", &e, 10)); ASSERT_STREQ("e-", e); ASSERT_EQ(0, strtoimax("-", &e, 10)); ASSERT_STREQ("-", e); ASSERT_EQ(0, strtoimax("0f", &e, 10)); ASSERT_STREQ("f", e); } TEST(strtoumax, testIBM) { char *e; ASSERT_EQ(1, strtoumax("1e-", &e, 10)); ASSERT_STREQ("e-", e); ASSERT_EQ(0, strtoumax("-", &e, 10)); ASSERT_STREQ("-", e); ASSERT_EQ(0, strtoumax("0f", &e, 10)); ASSERT_STREQ("f", e); } TEST(wcstol, testIBM) { wchar_t *e; ASSERT_EQ(1, wcstol(L"1e-", &e, 10)); ASSERT_STREQ(L"e-", e); ASSERT_EQ(0, wcstol(L"-", &e, 10)); ASSERT_STREQ(L"-", e); ASSERT_EQ(0, wcstol(L"0f", &e, 10)); ASSERT_STREQ(L"f", e); } TEST(wcstoul, testIBM) { wchar_t *e; ASSERT_EQ(1, wcstoul(L"1e-", &e, 10)); ASSERT_STREQ(L"e-", e); ASSERT_EQ(0, wcstoul(L"-", &e, 10)); ASSERT_STREQ(L"-", e); ASSERT_EQ(0, wcstoul(L"0f", &e, 10)); ASSERT_STREQ(L"f", e); } TEST(wcstoimax, testIBM) { wchar_t *e; ASSERT_EQ(1, wcstoimax(L"1e-", &e, 10)); ASSERT_STREQ(L"e-", e); ASSERT_EQ(0, wcstoimax(L"-", &e, 10)); ASSERT_STREQ(L"-", e); ASSERT_EQ(0, wcstoimax(L"0f", &e, 10)); ASSERT_STREQ(L"f", e); } TEST(wcstoumax, testIBM) { wchar_t *e; ASSERT_EQ(1, wcstoumax(L"1e-", &e, 10)); ASSERT_STREQ(L"e-", e); ASSERT_EQ(0, wcstoumax(L"-", &e, 10)); ASSERT_STREQ(L"-", e); ASSERT_EQ(0, wcstoumax(L"0f", &e, 10)); ASSERT_STREQ(L"f", e); } TEST(strtoul, testoverflow) { errno = 0; char *e = 0; unsigned long x = strtoul("18446744073709551616", &e, 0); ASSERT_EQ(ULONG_MAX, x); ASSERT_EQ(ERANGE, errno); ASSERT_STREQ("", e); } TEST(strtol, invalidHex_consistentWithBsd) { char *c = 0; long x = strtol("0xz", &c, 16); ASSERT_EQ(0, x); ASSERT_STREQ("z", c); } TEST(strtol, invalidHex_consistentWithBsd2) { char *c = 0; long x = strtol("0xez", &c, 16); ASSERT_EQ(0xe, x); ASSERT_STREQ("z", c); } BENCH(atoi, bench) { EZBENCH2("atoi 10⁸", donothing, EXPROPRIATE(atoi(VEIL("r", "100000000")))); EZBENCH2("strtol 10⁸", donothing, EXPROPRIATE(strtol(VEIL("r", "100000000"), 0, 10))); EZBENCH2("strtoul 10⁸", donothing, EXPROPRIATE(strtol(VEIL("r", "100000000"), 0, 10))); EZBENCH2("wcstol 10⁸", donothing, EXPROPRIATE(wcstol(VEIL("r", L"100000000"), 0, 10))); EZBENCH2("wcstoul 10⁸", donothing, EXPROPRIATE(wcstol(VEIL("r", L"100000000"), 0, 10))); EZBENCH2("strtoimax 10⁸", donothing, EXPROPRIATE(strtoimax(VEIL("r", "100000000"), 0, 10))); EZBENCH2("strtoumax 10⁸", donothing, EXPROPRIATE(strtoimax(VEIL("r", "100000000"), 0, 10))); EZBENCH2("wcstoimax 10⁸", donothing, EXPROPRIATE(wcstoimax(VEIL("r", L"100000000"), 0, 10))); EZBENCH2("wcstoumax 10⁸", donothing, EXPROPRIATE(wcstoimax(VEIL("r", L"100000000"), 0, 10))); EZBENCH2("strtoi128 10⁸", donothing, EXPROPRIATE(strtoi128(VEIL("r", "100000000"), 0, 10))); EZBENCH2("strtou128 10⁸", donothing, EXPROPRIATE(strtoi128(VEIL("r", "100000000"), 0, 10))); EZBENCH2("wcstoi128 10⁸", donothing, EXPROPRIATE(wcstoi128(VEIL("r", L"100000000"), 0, 10))); EZBENCH2("wcstou128 10⁸", donothing, EXPROPRIATE(wcstoi128(VEIL("r", L"100000000"), 0, 10))); }
19,851
602
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_popular_binary_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" TEST(x86ild, test_4883EC00) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMb ISA_SET: I86 SHORT: sub rsp, 0x0 */ EXPECT_EQ(4, ild(u"Hâ∞ ")); } TEST(x86ild, test_483D00000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_OrAX_IMMz ISA_SET: I86 SHORT: cmp rax, 0x0 */ EXPECT_EQ(6, ild(u"H=    ")); } TEST(x86ild, test_48F7F6) { /* ICLASS: DIV CATEGORY: BINARY EXTENSION: BASE IFORM: DIV_GPRv ISA_SET: I86 SHORT: div rsi */ EXPECT_EQ(3, ild(u"H≈÷")); } TEST(x86ild, test_4839F1) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rcx, rsi */ EXPECT_EQ(3, ild(u"H9±")); } TEST(x86ild, test_4839F0) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rax, rsi */ EXPECT_EQ(3, ild(u"H9≡")); } TEST(x86ild, test_807B0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_IMMb_80r7 ISA_SET: I86 SHORT: cmp byte ptr [rbx], 0x0 */ EXPECT_EQ(4, ild(u"Ç{  ")); } TEST(x86ild, test_4839D0) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rax, rdx */ EXPECT_EQ(3, ild(u"H9╨")); } TEST(x86ild, test_3C00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_AL_IMMb ISA_SET: I86 SHORT: cmp al, 0x0 */ EXPECT_EQ(2, ild(u"< ")); } TEST(x86ild, test_4883F800) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp rax, 0x0 */ EXPECT_EQ(4, ild(u"Hâ° ")); } TEST(x86ild, test_FEC8) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPR8 ISA_SET: I86 SHORT: dec al */ EXPECT_EQ(2, ild(u"■╚")); } TEST(x86ild, test_4801D0) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rax, rdx */ EXPECT_EQ(3, ild(u"H☺╨")); } TEST(x86ild, test_83F800) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp eax, 0x0 */ EXPECT_EQ(3, ild(u"â° ")); } TEST(x86ild, test_4883FA00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp rdx, 0x0 */ EXPECT_EQ(4, ild(u"Hâ· ")); } TEST(x86ild, test_3D00000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_OrAX_IMMz ISA_SET: I86 SHORT: cmp eax, 0x0 */ EXPECT_EQ(5, ild(u"=    ")); } TEST(x86ild, test_6683F800) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp ax, 0x0 */ EXPECT_EQ(4, ild(u"fâ° ")); } TEST(x86ild, test_80FA00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_IMMb_80r7 ISA_SET: I86 SHORT: cmp dl, 0x0 */ EXPECT_EQ(3, ild(u"Ç· ")); } TEST(x86ild, test_6683FA00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp dx, 0x0 */ EXPECT_EQ(4, ild(u"fâ· ")); } TEST(x86ild, test_83FA00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp edx, 0x0 */ EXPECT_EQ(3, ild(u"â· ")); } TEST(x86ild, test_663D0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_OrAX_IMMz ISA_SET: I86 SHORT: cmp ax, 0x0 */ EXPECT_EQ(4, ild(u"f=  ")); } TEST(x86ild, test_83FE00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp esi, 0x0 */ EXPECT_EQ(3, ild(u"â■ ")); } TEST(x86ild, test_4883C400) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_IMMb ISA_SET: I86 SHORT: add rsp, 0x0 */ EXPECT_EQ(4, ild(u"Hâ─ ")); } TEST(x86ild, test_01D2) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add edx, edx */ EXPECT_EQ(2, ild(u"☺╥")); } TEST(x86ild, test_80F900) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_IMMb_80r7 ISA_SET: I86 SHORT: cmp cl, 0x0 */ EXPECT_EQ(3, ild(u"Ç∙ ")); } TEST(x86ild, test_4801C8) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rax, rcx */ EXPECT_EQ(3, ild(u"H☺╚")); } TEST(x86ild, test_4883F900) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp rcx, 0x0 */ EXPECT_EQ(4, ild(u"Hâ∙ ")); } TEST(x86ild, test_4839C2) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rdx, rax */ EXPECT_EQ(3, ild(u"H9┬")); } TEST(x86ild, test_01C0) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add eax, eax */ EXPECT_EQ(2, ild(u"☺└")); } TEST(x86ild, test_83FF00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp edi, 0x0 */ EXPECT_EQ(3, ild(u"âλ ")); } TEST(x86ild, test_4183FC00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp r12d, 0x0 */ EXPECT_EQ(4, ild(u"Aâⁿ ")); } TEST(x86ild, test_01D0) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add eax, edx */ EXPECT_EQ(2, ild(u"☺╨")); } TEST(x86ild, test_6683F900) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp cx, 0x0 */ EXPECT_EQ(4, ild(u"fâ∙ ")); } TEST(x86ild, test_4883C300) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_IMMb ISA_SET: I86 SHORT: add rbx, 0x0 */ EXPECT_EQ(4, ild(u"Hâ├ ")); } TEST(x86ild, test_0000) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_MEMb_GPR8 ISA_SET: I86 SHORT: add byte ptr [rax], al */ EXPECT_EQ(2, ild(u"  ")); } TEST(x86ild, test_FECA) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPR8 ISA_SET: I86 SHORT: dec dl */ EXPECT_EQ(2, ild(u"■╩")); } TEST(x86ild, test_4801C2) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rdx, rax */ EXPECT_EQ(3, ild(u"H☺┬")); } TEST(x86ild, test_807F0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_IMMb_80r7 ISA_SET: I86 SHORT: cmp byte ptr [rdi], 0x0 */ EXPECT_EQ(4, ild(u"Ç⌂  ")); } TEST(x86ild, test_4801C1) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rcx, rax */ EXPECT_EQ(3, ild(u"H☺┴")); } TEST(x86ild, test_FFC3) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc ebx */ EXPECT_EQ(2, ild(u"λ├")); } TEST(x86ild, test_83F900) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp ecx, 0x0 */ EXPECT_EQ(3, ild(u"â∙ ")); } TEST(x86ild, test_83E800) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMb ISA_SET: I86 SHORT: sub eax, 0x0 */ EXPECT_EQ(3, ild(u"âΦ ")); } TEST(x86ild, test_FFCE) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPRv_FFr1 ISA_SET: I86 SHORT: dec esi */ EXPECT_EQ(2, ild(u"λ╬")); } TEST(x86ild, test_83780000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMv_IMMb ISA_SET: I86 SHORT: cmp dword ptr [rax], 0x0 */ EXPECT_EQ(4, ild(u"âx  ")); } TEST(x86ild, test_81FF00000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMz ISA_SET: I86 SHORT: cmp edi, 0x0 */ EXPECT_EQ(6, ild(u"üλ    ")); } TEST(x86ild, test_FFC8) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPRv_FFr1 ISA_SET: I86 SHORT: dec eax */ EXPECT_EQ(2, ild(u"λ╚")); } TEST(x86ild, test_80780000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_IMMb_80r7 ISA_SET: I86 SHORT: cmp byte ptr [rax], 0x0 */ EXPECT_EQ(4, ild(u"Çx  ")); } TEST(x86ild, test_4839C8) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rax, rcx */ EXPECT_EQ(3, ild(u"H9╚")); } TEST(x86ild, test_803800) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_IMMb_80r7 ISA_SET: I86 SHORT: cmp byte ptr [rax], 0x0 */ EXPECT_EQ(3, ild(u"Ç8 ")); } TEST(x86ild, test_4883E800) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMb ISA_SET: I86 SHORT: sub rax, 0x0 */ EXPECT_EQ(4, ild(u"HâΦ ")); } TEST(x86ild, test_4080FE00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_IMMb_80r7 ISA_SET: I86 SHORT: cmp sil, 0x0 */ EXPECT_EQ(4, ild(u"@Ç■ ")); } TEST(x86ild, test_FFC5) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc ebp */ EXPECT_EQ(2, ild(u"λ┼")); } TEST(x86ild, test_807D0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_IMMb_80r7 ISA_SET: I86 SHORT: cmp byte ptr [rbp], 0x0 */ EXPECT_EQ(4, ild(u"Ç}  ")); } TEST(x86ild, test_4883C000) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_IMMb ISA_SET: I86 SHORT: add rax, 0x0 */ EXPECT_EQ(4, ild(u"Hâ└ ")); } TEST(x86ild, test_480500000000) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_OrAX_IMMz ISA_SET: I86 SHORT: add rax, 0x0 */ EXPECT_EQ(6, ild(u"H♣    ")); } TEST(x86ild, test_00FF) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPR8_GPR8_00 ISA_SET: I86 SHORT: add bh, bh */ EXPECT_EQ(2, ild(u" λ")); } TEST(x86ild, test_FFC1) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc ecx */ EXPECT_EQ(2, ild(u"λ┴")); } TEST(x86ild, test_83B80000000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMv_IMMb ISA_SET: I86 SHORT: cmp dword ptr [rax], 0x0 */ EXPECT_EQ(7, ild(u"â╕     ")); } TEST(x86ild, test_48FFC0) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc rax */ EXPECT_EQ(3, ild(u"Hλ└")); } TEST(x86ild, test_4881FF00000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMz ISA_SET: I86 SHORT: cmp rdi, 0x0 */ EXPECT_EQ(7, ild(u"Hüλ    ")); } TEST(x86ild, test_4839CA) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rdx, rcx */ EXPECT_EQ(3, ild(u"H9╩")); } TEST(x86ild, test_4839C1) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rcx, rax */ EXPECT_EQ(3, ild(u"H9┴")); } TEST(x86ild, test_4801DF) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rdi, rbx */ EXPECT_EQ(3, ild(u"H☺▀")); } TEST(x86ild, test_19C0) { /* ICLASS: SBB CATEGORY: BINARY EXTENSION: BASE IFORM: SBB_GPRv_GPRv_19 ISA_SET: I86 SHORT: sbb eax, eax */ EXPECT_EQ(2, ild(u"↓└")); } TEST(x86ild, test_833D0000000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMv_IMMb ISA_SET: I86 SHORT: cmp dword ptr [rip], 0x0 */ EXPECT_EQ(7, ild(u"â=     ")); } TEST(x86ild, test_4801F0) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rax, rsi */ EXPECT_EQ(3, ild(u"H☺≡")); } TEST(x86ild, test_4801C0) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rax, rax */ EXPECT_EQ(3, ild(u"H☺└")); } TEST(x86ild, test_FFCA) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPRv_FFr1 ISA_SET: I86 SHORT: dec edx */ EXPECT_EQ(2, ild(u"λ╩")); } TEST(x86ild, test_FEC9) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPR8 ISA_SET: I86 SHORT: dec cl */ EXPECT_EQ(2, ild(u"■╔")); } TEST(x86ild, test_83FB00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp ebx, 0x0 */ EXPECT_EQ(3, ild(u"â√ ")); } TEST(x86ild, test_48FFC8) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPRv_FFr1 ISA_SET: I86 SHORT: dec rax */ EXPECT_EQ(3, ild(u"Hλ╚")); } TEST(x86ild, test_48FFC2) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc rdx */ EXPECT_EQ(3, ild(u"Hλ┬")); } TEST(x86ild, test_48F7F7) { /* ICLASS: DIV CATEGORY: BINARY EXTENSION: BASE IFORM: DIV_GPRv ISA_SET: I86 SHORT: div rdi */ EXPECT_EQ(3, ild(u"H≈≈")); } TEST(x86ild, test_4883FB00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp rbx, 0x0 */ EXPECT_EQ(4, ild(u"Hâ√ ")); } TEST(x86ild, test_4839F8) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rax, rdi */ EXPECT_EQ(3, ild(u"H9°")); } TEST(x86ild, test_4801D1) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rcx, rdx */ EXPECT_EQ(3, ild(u"H☺╤")); } TEST(x86ild, test_4801CA) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rdx, rcx */ EXPECT_EQ(3, ild(u"H☺╩")); } TEST(x86ild, test_4080FF00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_IMMb_80r7 ISA_SET: I86 SHORT: cmp dil, 0x0 */ EXPECT_EQ(4, ild(u"@Çλ ")); } TEST(x86ild, test_FFC2) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc edx */ EXPECT_EQ(2, ild(u"λ┬")); } TEST(x86ild, test_FFC0) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc eax */ EXPECT_EQ(2, ild(u"λ└")); } TEST(x86ild, test_83FD00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp ebp, 0x0 */ EXPECT_EQ(3, ild(u"â² ")); } TEST(x86ild, test_83C200) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_IMMb ISA_SET: I86 SHORT: add edx, 0x0 */ EXPECT_EQ(3, ild(u"â┬ ")); } TEST(x86ild, test_83C100) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_IMMb ISA_SET: I86 SHORT: add ecx, 0x0 */ EXPECT_EQ(3, ild(u"â┴ ")); } TEST(x86ild, test_4881EC00000000) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMz ISA_SET: I86 SHORT: sub rsp, 0x0 */ EXPECT_EQ(7, ild(u"Hü∞    ")); } TEST(x86ild, test_4881C400000000) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_IMMz ISA_SET: I86 SHORT: add rsp, 0x0 */ EXPECT_EQ(7, ild(u"Hü─    ")); } TEST(x86ild, test_482D00000000) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_OrAX_IMMz ISA_SET: I86 SHORT: sub rax, 0x0 */ EXPECT_EQ(6, ild(u"H-    ")); } TEST(x86ild, test_4801C6) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rsi, rax */ EXPECT_EQ(3, ild(u"H☺╞")); } TEST(x86ild, test_4439F3) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ebx, r14d */ EXPECT_EQ(3, ild(u"D9≤")); } TEST(x86ild, test_41FFC8) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPRv_FFr1 ISA_SET: I86 SHORT: dec r8d */ EXPECT_EQ(3, ild(u"Aλ╚")); } TEST(x86ild, test_41FFC4) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc r12d */ EXPECT_EQ(3, ild(u"Aλ─")); } TEST(x86ild, test_4183FD00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp r13d, 0x0 */ EXPECT_EQ(4, ild(u"Aâ² ")); } TEST(x86ild, test_4180F800) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_IMMb_80r7 ISA_SET: I86 SHORT: cmp r8b, 0x0 */ EXPECT_EQ(4, ild(u"AÇ° ")); } TEST(x86ild, test_39F1) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ecx, esi */ EXPECT_EQ(2, ild(u"9±")); } TEST(x86ild, test_39F0) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp eax, esi */ EXPECT_EQ(2, ild(u"9≡")); } TEST(x86ild, test_FFC6) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc esi */ EXPECT_EQ(2, ild(u"λ╞")); } TEST(x86ild, test_837D0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMv_IMMb ISA_SET: I86 SHORT: cmp dword ptr [rbp], 0x0 */ EXPECT_EQ(4, ild(u"â}  ")); } TEST(x86ild, test_833CD50000000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMv_IMMb ISA_SET: I86 SHORT: cmp dword ptr [rdx*8], 0x0 */ EXPECT_EQ(8, ild(u"â<╒     ")); } TEST(x86ild, test_81EB00000000) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMz ISA_SET: I86 SHORT: sub ebx, 0x0 */ EXPECT_EQ(6, ild(u"üδ    ")); } TEST(x86ild, test_807A0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_IMMb_80r7 ISA_SET: I86 SHORT: cmp byte ptr [rdx], 0x0 */ EXPECT_EQ(4, ild(u"Çz  ")); } TEST(x86ild, test_4C01C0) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rax, r8 */ EXPECT_EQ(3, ild(u"L☺└")); } TEST(x86ild, test_49FFC0) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc r8 */ EXPECT_EQ(3, ild(u"Iλ└")); } TEST(x86ild, test_4901D1) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add r9, rdx */ EXPECT_EQ(3, ild(u"I☺╤")); } TEST(x86ild, test_48FFC7) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc rdi */ EXPECT_EQ(3, ild(u"Hλ╟")); } TEST(x86ild, test_48FFC1) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc rcx */ EXPECT_EQ(3, ild(u"Hλ┴")); } TEST(x86ild, test_4883FF00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp rdi, 0x0 */ EXPECT_EQ(4, ild(u"Hâλ ")); } TEST(x86ild, test_4883EB00) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMb ISA_SET: I86 SHORT: sub rbx, 0x0 */ EXPECT_EQ(4, ild(u"Hâδ ")); } TEST(x86ild, test_4883C200) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_IMMb ISA_SET: I86 SHORT: add rdx, 0x0 */ EXPECT_EQ(4, ild(u"Hâ┬ ")); } TEST(x86ild, test_4839D8) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rax, rbx */ EXPECT_EQ(3, ild(u"H9╪")); } TEST(x86ild, test_48034700) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_MEMv ISA_SET: I86 SHORT: add rax, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"H♥G ")); } TEST(x86ild, test_4801F2) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rdx, rsi */ EXPECT_EQ(3, ild(u"H☺≥")); } TEST(x86ild, test_4539FE) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r14d, r15d */ EXPECT_EQ(3, ild(u"E9■")); } TEST(x86ild, test_4429E1) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub ecx, r12d */ EXPECT_EQ(3, ild(u"D)ß")); } TEST(x86ild, test_41807C240000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_IMMb_80r7 ISA_SET: I86 SHORT: cmp byte ptr [r12], 0x0 */ EXPECT_EQ(6, ild(u"AÇ|$  ")); } TEST(x86ild, test_39D0) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp eax, edx */ EXPECT_EQ(2, ild(u"9╨")); } TEST(x86ild, test_39C2) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp edx, eax */ EXPECT_EQ(2, ild(u"9┬")); } TEST(x86ild, test_39C1) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ecx, eax */ EXPECT_EQ(2, ild(u"9┴")); } TEST(x86ild, test_0FAFC2) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv ISA_SET: I86 SHORT: imul eax, edx */ EXPECT_EQ(3, ild(u"☼»┬")); } TEST(x86ild, test_01C1) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add ecx, eax */ EXPECT_EQ(2, ild(u"☺┴")); } TEST(x86ild, test_FE4300) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_MEMb ISA_SET: I86 SHORT: inc byte ptr [rbx] */ EXPECT_EQ(3, ild(u"■C ")); } TEST(x86ild, test_F7DB) { /* ICLASS: NEG CATEGORY: BINARY EXTENSION: BASE IFORM: NEG_GPRv ISA_SET: I86 SHORT: neg ebx */ EXPECT_EQ(2, ild(u"≈█")); } TEST(x86ild, test_F77500) { /* ICLASS: DIV CATEGORY: BINARY EXTENSION: BASE IFORM: DIV_MEMv ISA_SET: I86 SHORT: div dword ptr [rbp] */ EXPECT_EQ(3, ild(u"≈u ")); } TEST(x86ild, test_83EA00) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMb ISA_SET: I86 SHORT: sub edx, 0x0 */ EXPECT_EQ(3, ild(u"âΩ ")); } TEST(x86ild, test_83E900) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMb ISA_SET: I86 SHORT: sub ecx, 0x0 */ EXPECT_EQ(3, ild(u"âΘ ")); } TEST(x86ild, test_83C700) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_IMMb ISA_SET: I86 SHORT: add edi, 0x0 */ EXPECT_EQ(3, ild(u"â╟ ")); } TEST(x86ild, test_837F0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMv_IMMb ISA_SET: I86 SHORT: cmp dword ptr [rdi], 0x0 */ EXPECT_EQ(4, ild(u"â⌂  ")); } TEST(x86ild, test_833C2400) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMv_IMMb ISA_SET: I86 SHORT: cmp dword ptr [rsp], 0x0 */ EXPECT_EQ(4, ild(u"â<$ ")); } TEST(x86ild, test_81FA00000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMz ISA_SET: I86 SHORT: cmp edx, 0x0 */ EXPECT_EQ(6, ild(u"ü·    ")); } TEST(x86ild, test_803D0000000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_IMMb_80r7 ISA_SET: I86 SHORT: cmp byte ptr [rip], 0x0 */ EXPECT_EQ(7, ild(u"Ç=     ")); } TEST(x86ild, test_6683780000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMv_IMMb ISA_SET: I86 SHORT: cmp word ptr [rax], 0x0 */ EXPECT_EQ(5, ild(u"fâx  ")); } TEST(x86ild, test_6681FD0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMz ISA_SET: I86 SHORT: cmp bp, 0x0 */ EXPECT_EQ(5, ild(u"fü²  ")); } TEST(x86ild, test_6681FA0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMz ISA_SET: I86 SHORT: cmp dx, 0x0 */ EXPECT_EQ(5, ild(u"fü·  ")); } TEST(x86ild, test_6681C20000) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_IMMz ISA_SET: I86 SHORT: add dx, 0x0 */ EXPECT_EQ(5, ild(u"fü┬  ")); } TEST(x86ild, test_6639D0) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ax, dx */ EXPECT_EQ(3, ild(u"f9╨")); } TEST(x86ild, test_6639CA) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp dx, cx */ EXPECT_EQ(3, ild(u"f9╩")); } TEST(x86ild, test_4C29C0) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub rax, r8 */ EXPECT_EQ(3, ild(u"L)└")); } TEST(x86ild, test_4C034F00) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_MEMv ISA_SET: I86 SHORT: add r9, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"L♥O ")); } TEST(x86ild, test_4C01E8) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rax, r13 */ EXPECT_EQ(3, ild(u"L☺Φ")); } TEST(x86ild, test_4C01E0) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rax, r12 */ EXPECT_EQ(3, ild(u"L☺α")); } TEST(x86ild, test_49FFC5) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc r13 */ EXPECT_EQ(3, ild(u"Iλ┼")); } TEST(x86ild, test_49F7F1) { /* ICLASS: DIV CATEGORY: BINARY EXTENSION: BASE IFORM: DIV_GPRv ISA_SET: I86 SHORT: div r9 */ EXPECT_EQ(3, ild(u"I≈±")); } TEST(x86ild, test_49F7DC) { /* ICLASS: NEG CATEGORY: BINARY EXTENSION: BASE IFORM: NEG_GPRv ISA_SET: I86 SHORT: neg r12 */ EXPECT_EQ(3, ild(u"I≈▄")); } TEST(x86ild, test_4929C2) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub r10, rax */ EXPECT_EQ(3, ild(u"I)┬")); } TEST(x86ild, test_48FFC9) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPRv_FFr1 ISA_SET: I86 SHORT: dec rcx */ EXPECT_EQ(3, ild(u"Hλ╔")); } TEST(x86ild, test_48FFC6) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc rsi */ EXPECT_EQ(3, ild(u"Hλ╞")); } TEST(x86ild, test_48FFC5) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc rbp */ EXPECT_EQ(3, ild(u"Hλ┼")); } TEST(x86ild, test_48F7F1) { /* ICLASS: DIV CATEGORY: BINARY EXTENSION: BASE IFORM: DIV_GPRv ISA_SET: I86 SHORT: div rcx */ EXPECT_EQ(3, ild(u"H≈±")); } TEST(x86ild, test_48F7DB) { /* ICLASS: NEG CATEGORY: BINARY EXTENSION: BASE IFORM: NEG_GPRv ISA_SET: I86 SHORT: neg rbx */ EXPECT_EQ(3, ild(u"H≈█")); } TEST(x86ild, test_4883FE00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp rsi, 0x0 */ EXPECT_EQ(4, ild(u"Hâ■ ")); } TEST(x86ild, test_48837F0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMv_IMMb ISA_SET: I86 SHORT: cmp qword ptr [rdi], 0x0 */ EXPECT_EQ(5, ild(u"Hâ⌂  ")); } TEST(x86ild, test_4881EE00000000) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMz ISA_SET: I86 SHORT: sub rsi, 0x0 */ EXPECT_EQ(7, ild(u"Hüε    ")); } TEST(x86ild, test_4881EB00000000) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_IMMz ISA_SET: I86 SHORT: sub rbx, 0x0 */ EXPECT_EQ(7, ild(u"Hüδ    ")); } TEST(x86ild, test_4839F2) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rdx, rsi */ EXPECT_EQ(3, ild(u"H9≥")); } TEST(x86ild, test_4839D6) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rsi, rdx */ EXPECT_EQ(3, ild(u"H9╓")); } TEST(x86ild, test_4839C7) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp rdi, rax */ EXPECT_EQ(3, ild(u"H9╟")); } TEST(x86ild, test_4829DA) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub rdx, rbx */ EXPECT_EQ(3, ild(u"H)┌")); } TEST(x86ild, test_480FAFD0) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv ISA_SET: I86 SHORT: imul rdx, rax */ EXPECT_EQ(4, ild(u"H☼»╨")); } TEST(x86ild, test_480FAFCA) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv ISA_SET: I86 SHORT: imul rcx, rdx */ EXPECT_EQ(4, ild(u"H☼»╩")); } TEST(x86ild, test_480FAFC8) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv ISA_SET: I86 SHORT: imul rcx, rax */ EXPECT_EQ(4, ild(u"H☼»╚")); } TEST(x86ild, test_48035300) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_MEMv ISA_SET: I86 SHORT: add rdx, qword ptr [rbx] */ EXPECT_EQ(4, ild(u"H♥S ")); } TEST(x86ild, test_4801F8) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rax, rdi */ EXPECT_EQ(3, ild(u"H☺°")); } TEST(x86ild, test_4801EF) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rdi, rbp */ EXPECT_EQ(3, ild(u"H☺∩")); } TEST(x86ild, test_4801DE) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rsi, rbx */ EXPECT_EQ(3, ild(u"H☺▐")); } TEST(x86ild, test_4801D2) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add rdx, rdx */ EXPECT_EQ(3, ild(u"H☺╥")); } TEST(x86ild, test_4539F4) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r12d, r14d */ EXPECT_EQ(3, ild(u"E9⌠")); } TEST(x86ild, test_4539EF) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r15d, r13d */ EXPECT_EQ(3, ild(u"E9∩")); } TEST(x86ild, test_4539EE) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r14d, r13d */ EXPECT_EQ(3, ild(u"E9ε")); } TEST(x86ild, test_4529C4) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub r12d, r8d */ EXPECT_EQ(3, ild(u"E)─")); } TEST(x86ild, test_4501E4) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add r12d, r12d */ EXPECT_EQ(3, ild(u"E☺Σ")); } TEST(x86ild, test_4501E2) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add r10d, r12d */ EXPECT_EQ(3, ild(u"E☺Γ")); } TEST(x86ild, test_4439E8) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp eax, r13d */ EXPECT_EQ(3, ild(u"D9Φ")); } TEST(x86ild, test_4439E5) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ebp, r12d */ EXPECT_EQ(3, ild(u"D9σ")); } TEST(x86ild, test_4439E3) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ebx, r12d */ EXPECT_EQ(3, ild(u"D9π")); } TEST(x86ild, test_4439E1) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ecx, r12d */ EXPECT_EQ(3, ild(u"D9ß")); } TEST(x86ild, test_4439C9) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ecx, r9d */ EXPECT_EQ(3, ild(u"D9╔")); } TEST(x86ild, test_4439C7) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp edi, r8d */ EXPECT_EQ(3, ild(u"D9╟")); } TEST(x86ild, test_4439C5) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ebp, r8d */ EXPECT_EQ(3, ild(u"D9┼")); } TEST(x86ild, test_4439C2) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp edx, r8d */ EXPECT_EQ(3, ild(u"D9┬")); } TEST(x86ild, test_4438C1) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_GPR8_38 ISA_SET: I86 SHORT: cmp cl, r8b */ EXPECT_EQ(3, ild(u"D8┴")); } TEST(x86ild, test_4429DD) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub ebp, r11d */ EXPECT_EQ(3, ild(u"D)▌")); } TEST(x86ild, test_4429D1) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub ecx, r10d */ EXPECT_EQ(3, ild(u"D)╤")); } TEST(x86ild, test_4429C0) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub eax, r8d */ EXPECT_EQ(3, ild(u"D)└")); } TEST(x86ild, test_4401E8) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add eax, r13d */ EXPECT_EQ(3, ild(u"D☺Φ")); } TEST(x86ild, test_4401C8) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add eax, r9d */ EXPECT_EQ(3, ild(u"D☺╚")); } TEST(x86ild, test_41FFCF) { /* ICLASS: DEC CATEGORY: BINARY EXTENSION: BASE IFORM: DEC_GPRv_FFr1 ISA_SET: I86 SHORT: dec r15d */ EXPECT_EQ(3, ild(u"Aλ╧")); } TEST(x86ild, test_41FFC7) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc r15d */ EXPECT_EQ(3, ild(u"Aλ╟")); } TEST(x86ild, test_41FFC6) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc r14d */ EXPECT_EQ(3, ild(u"Aλ╞")); } TEST(x86ild, test_41FFC2) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc r10d */ EXPECT_EQ(3, ild(u"Aλ┬")); } TEST(x86ild, test_41FFC1) { /* ICLASS: INC CATEGORY: BINARY EXTENSION: BASE IFORM: INC_GPRv_FFr0 ISA_SET: I86 SHORT: inc r9d */ EXPECT_EQ(3, ild(u"Aλ┴")); } TEST(x86ild, test_4183FE00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp r14d, 0x0 */ EXPECT_EQ(4, ild(u"Aâ■ ")); } TEST(x86ild, test_4183FB00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp r11d, 0x0 */ EXPECT_EQ(4, ild(u"Aâ√ ")); } TEST(x86ild, test_4183F900) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp r9d, 0x0 */ EXPECT_EQ(4, ild(u"Aâ∙ ")); } TEST(x86ild, test_4183F800) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMb ISA_SET: I86 SHORT: cmp r8d, 0x0 */ EXPECT_EQ(4, ild(u"Aâ° ")); } TEST(x86ild, test_4181F800000000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_IMMz ISA_SET: I86 SHORT: cmp r8d, 0x0 */ EXPECT_EQ(7, ild(u"Aü°    ")); } TEST(x86ild, test_4180F900) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_IMMb_80r7 ISA_SET: I86 SHORT: cmp r9b, 0x0 */ EXPECT_EQ(4, ild(u"AÇ∙ ")); } TEST(x86ild, test_41803C0000) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_IMMb_80r7 ISA_SET: I86 SHORT: cmp byte ptr [r8+rax*1], 0x0 */ EXPECT_EQ(5, ild(u"AÇ<  ")); } TEST(x86ild, test_4139F5) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r13d, esi */ EXPECT_EQ(3, ild(u"A9⌡")); } TEST(x86ild, test_4139EE) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r14d, ebp */ EXPECT_EQ(3, ild(u"A9ε")); } TEST(x86ild, test_4139EC) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r12d, ebp */ EXPECT_EQ(3, ild(u"A9∞")); } TEST(x86ild, test_4139DD) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r13d, ebx */ EXPECT_EQ(3, ild(u"A9▌")); } TEST(x86ild, test_4139D1) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r9d, edx */ EXPECT_EQ(3, ild(u"A9╤")); } TEST(x86ild, test_4139D0) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r8d, edx */ EXPECT_EQ(3, ild(u"A9╨")); } TEST(x86ild, test_4139C6) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r14d, eax */ EXPECT_EQ(3, ild(u"A9╞")); } TEST(x86ild, test_4139C4) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r12d, eax */ EXPECT_EQ(3, ild(u"A9─")); } TEST(x86ild, test_4139C1) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp r9d, eax */ EXPECT_EQ(3, ild(u"A9┴")); } TEST(x86ild, test_4138ED) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_GPR8_38 ISA_SET: I86 SHORT: cmp r13b, bpl */ EXPECT_EQ(3, ild(u"A8φ")); } TEST(x86ild, test_4129CC) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub r12d, ecx */ EXPECT_EQ(3, ild(u"A)╠")); } TEST(x86ild, test_4038F1) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_GPR8_38 ISA_SET: I86 SHORT: cmp cl, sil */ EXPECT_EQ(3, ild(u"@8±")); } TEST(x86ild, test_3A5300) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_MEMb ISA_SET: I86 SHORT: cmp dl, byte ptr [rbx] */ EXPECT_EQ(3, ild(u":S ")); } TEST(x86ild, test_3A4B00) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_MEMb ISA_SET: I86 SHORT: cmp cl, byte ptr [rbx] */ EXPECT_EQ(3, ild(u":K ")); } TEST(x86ild, test_3A4300) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPR8_MEMb ISA_SET: I86 SHORT: cmp al, byte ptr [rbx] */ EXPECT_EQ(3, ild(u":C ")); } TEST(x86ild, test_39F9) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ecx, edi */ EXPECT_EQ(2, ild(u"9∙")); } TEST(x86ild, test_39F7) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp edi, esi */ EXPECT_EQ(2, ild(u"9≈")); } TEST(x86ild, test_39EB) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ebx, ebp */ EXPECT_EQ(2, ild(u"9δ")); } TEST(x86ild, test_39D8) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp eax, ebx */ EXPECT_EQ(2, ild(u"9╪")); } TEST(x86ild, test_39CA) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp edx, ecx */ EXPECT_EQ(2, ild(u"9╩")); } TEST(x86ild, test_39C5) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ebp, eax */ EXPECT_EQ(2, ild(u"9┼")); } TEST(x86ild, test_39C3) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_GPRv_GPRv_39 ISA_SET: I86 SHORT: cmp ebx, eax */ EXPECT_EQ(2, ild(u"9├")); } TEST(x86ild, test_385700) { /* ICLASS: CMP CATEGORY: BINARY EXTENSION: BASE IFORM: CMP_MEMb_GPR8 ISA_SET: I86 SHORT: cmp byte ptr [rdi], dl */ EXPECT_EQ(3, ild(u"8W ")); } TEST(x86ild, test_29E8) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub eax, ebp */ EXPECT_EQ(2, ild(u")Φ")); } TEST(x86ild, test_29DD) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub ebp, ebx */ EXPECT_EQ(2, ild(u")▌")); } TEST(x86ild, test_29C5) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub ebp, eax */ EXPECT_EQ(2, ild(u")┼")); } TEST(x86ild, test_29C3) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub ebx, eax */ EXPECT_EQ(2, ild(u")├")); } TEST(x86ild, test_29C2) { /* ICLASS: SUB CATEGORY: BINARY EXTENSION: BASE IFORM: SUB_GPRv_GPRv_29 ISA_SET: I86 SHORT: sub edx, eax */ EXPECT_EQ(2, ild(u")┬")); } TEST(x86ild, test_01FE) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add esi, edi */ EXPECT_EQ(2, ild(u"☺■")); } TEST(x86ild, test_01F0) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add eax, esi */ EXPECT_EQ(2, ild(u"☺≡")); } TEST(x86ild, test_01D6) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add esi, edx */ EXPECT_EQ(2, ild(u"☺╓")); } TEST(x86ild, test_01C9) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add ecx, ecx */ EXPECT_EQ(2, ild(u"☺╔")); } TEST(x86ild, test_01C8) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add eax, ecx */ EXPECT_EQ(2, ild(u"☺╚")); } TEST(x86ild, test_01C5) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add ebp, eax */ EXPECT_EQ(2, ild(u"☺┼")); } TEST(x86ild, test_01C2) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPRv_GPRv_01 ISA_SET: I86 SHORT: add edx, eax */ EXPECT_EQ(2, ild(u"☺┬")); } TEST(x86ild, test_01B000000000) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_MEMv_GPRv ISA_SET: I86 SHORT: add dword ptr [rax], esi */ EXPECT_EQ(6, ild(u"☺░    ")); } TEST(x86ild, test_00C1) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_GPR8_GPR8_00 ISA_SET: I86 SHORT: add cl, al */ EXPECT_EQ(2, ild(u" ┴")); } TEST(x86ild, test_00B800000000) { /* ICLASS: ADD CATEGORY: BINARY EXTENSION: BASE IFORM: ADD_MEMb_GPR8 ISA_SET: I86 SHORT: add byte ptr [rax], bh */ EXPECT_EQ(6, ild(u" ╕    ")); }
47,981
2,794
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_popular_i86_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" /** * @fileoverview GCC's popular i386+ instruction w/ NexGen32e encoding. */ TEST(x86ild, test_E800000000) { /* ICLASS: CALL_NEAR CATEGORY: CALL EXTENSION: BASE IFORM: CALL_NEAR_RELBRd ISA_SET: I86 SHORT: call 0x5 */ EXPECT_EQ(5, ild(u"Φ    ")); EXPECT_EQ(5, ildlegacy(u"Φ    ")); EXPECT_EQ(3, ildreal(u"Φ  ")); } TEST(x86ild, test_C3) { /* ICLASS: RET_NEAR CATEGORY: RET EXTENSION: BASE IFORM: RET_NEAR ISA_SET: I86 SHORT: ret */ EXPECT_EQ(1, ild(u"├")); } TEST(x86ild, test_5A) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop rdx */ EXPECT_EQ(1, ild(u"Z")); } TEST(x86ild, test_4889DF) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdi, rbx */ EXPECT_EQ(3, ild(u"Hë▀")); } TEST(x86ild, test_BA00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov edx, 0x0 */ EXPECT_EQ(5, ild(u"║    ")); } TEST(x86ild, test_7500) { /* ICLASS: JNZ CATEGORY: COND_BR EXTENSION: BASE IFORM: JNZ_RELBRb ISA_SET: I86 SHORT: jnz 0x2 */ EXPECT_EQ(2, ild(u"u ")); } TEST(x86ild, test_B800000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov eax, 0x0 */ EXPECT_EQ(5, ild(u"╕    ")); } TEST(x86ild, test_7400) { /* ICLASS: JZ CATEGORY: COND_BR EXTENSION: BASE IFORM: JZ_RELBRb ISA_SET: I86 SHORT: jz 0x2 */ EXPECT_EQ(2, ild(u"t ")); } TEST(x86ild, test_BE00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov esi, 0x0 */ EXPECT_EQ(5, ild(u"╛    ")); } TEST(x86ild, test_4889C1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rcx, rax */ EXPECT_EQ(3, ild(u"Hë┴")); } TEST(x86ild, test_EB00) { /* ICLASS: JMP CATEGORY: UNCOND_BR EXTENSION: BASE IFORM: JMP_RELBRb ISA_SET: I86 SHORT: jmp 0x2 */ EXPECT_EQ(2, ild(u"δ ")); } TEST(x86ild, test_8B34D500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov esi, dword ptr [rdx*8] */ EXPECT_EQ(7, ild(u"ï4╒    ")); } TEST(x86ild, test_E900000000) { /* ICLASS: JMP CATEGORY: UNCOND_BR EXTENSION: BASE IFORM: JMP_RELBRd ISA_SET: I86 SHORT: jmp 0x5 */ EXPECT_EQ(5, ild(u"Θ    ")); } TEST(x86ild, test_8B7300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov esi, dword ptr [rbx] */ EXPECT_EQ(3, ild(u"ïs ")); } TEST(x86ild, test_8B04D500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rdx*8] */ EXPECT_EQ(7, ild(u"ï♦╒    ")); } TEST(x86ild, test_89D0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, edx */ EXPECT_EQ(2, ild(u"ë╨")); } TEST(x86ild, test_0F8400000000) { /* ICLASS: JZ CATEGORY: COND_BR EXTENSION: BASE IFORM: JZ_RELBRd ISA_SET: I86 SHORT: jz 0x6 */ EXPECT_EQ(6, ild(u"☼ä    ")); } TEST(x86ild, test_8B14CD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rcx*8] */ EXPECT_EQ(7, ild(u"ï¶═    ")); } TEST(x86ild, test_8B34CD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov esi, dword ptr [rcx*8] */ EXPECT_EQ(7, ild(u"ï4═    ")); } TEST(x86ild, test_8A4300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rbx] */ EXPECT_EQ(3, ild(u"èC ")); } TEST(x86ild, test_8B4700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rdi] */ EXPECT_EQ(3, ild(u"ïG ")); } TEST(x86ild, test_5B) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop rbx */ EXPECT_EQ(1, ild(u"[")); } TEST(x86ild, test_66C705000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov word ptr [rip], 0x0 */ EXPECT_EQ(9, ild(u"f╟♣      ")); } TEST(x86ild, test_8A4700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rdi] */ EXPECT_EQ(3, ild(u"èG ")); } TEST(x86ild, test_FFD0) { /* ICLASS: CALL_NEAR CATEGORY: CALL EXTENSION: BASE IFORM: CALL_NEAR_GPRv ISA_SET: I86 SHORT: call rax */ EXPECT_EQ(2, ild(u"λ╨")); } TEST(x86ild, test_C7050000000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov dword ptr [rip], 0x0 */ EXPECT_EQ(10, ild(u"╟♣        ")); } TEST(x86ild, test_53) { /* ICLASS: PUSH CATEGORY: PUSH EXTENSION: BASE IFORM: PUSH_GPRv_50 ISA_SET: I86 SHORT: push rbx */ EXPECT_EQ(1, ild(u"S")); } TEST(x86ild, test_0F8500000000) { /* ICLASS: JNZ CATEGORY: COND_BR EXTENSION: BASE IFORM: JNZ_RELBRd ISA_SET: I86 SHORT: jnz 0x6 */ EXPECT_EQ(6, ild(u"☼à    ")); } TEST(x86ild, test_C6050000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rip], 0x0 */ EXPECT_EQ(7, ild(u"╞♣     ")); } TEST(x86ild, test_668B7300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov si, word ptr [rbx] */ EXPECT_EQ(4, ild(u"fïs ")); } TEST(x86ild, test_488B4300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rbx] */ EXPECT_EQ(4, ild(u"HïC ")); } TEST(x86ild, test_BF00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov edi, 0x0 */ EXPECT_EQ(5, ild(u"┐    ")); } TEST(x86ild, test_4889FB) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbx, rdi */ EXPECT_EQ(3, ild(u"Hë√")); } TEST(x86ild, test_48B80000000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov rax, 0x0 */ EXPECT_EQ(10, ild(u"H╕        ")); } TEST(x86ild, test_48BA0000000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov rdx, 0x0 */ EXPECT_EQ(10, ild(u"H║        ")); } TEST(x86ild, test_488B5300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rbx] */ EXPECT_EQ(4, ild(u"HïS ")); } TEST(x86ild, test_66898200000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rdx], ax */ EXPECT_EQ(7, ild(u"fëé    ")); } TEST(x86ild, test_66894700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rdi], ax */ EXPECT_EQ(4, ild(u"fëG ")); } TEST(x86ild, test_7700) { /* ICLASS: JNBE CATEGORY: COND_BR EXTENSION: BASE IFORM: JNBE_RELBRb ISA_SET: I86 SHORT: jnbe 0x2 */ EXPECT_EQ(2, ild(u"w ")); } TEST(x86ild, test_894700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdi], eax */ EXPECT_EQ(3, ild(u"ëG ")); } TEST(x86ild, test_66899000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rax], dx */ EXPECT_EQ(7, ild(u"fëÉ    ")); } TEST(x86ild, test_4889D0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rax, rdx */ EXPECT_EQ(3, ild(u"Hë╨")); } TEST(x86ild, test_668B4700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ax, word ptr [rdi] */ EXPECT_EQ(4, ild(u"fïG ")); } TEST(x86ild, test_89C2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edx, eax */ EXPECT_EQ(2, ild(u"ë┬")); } TEST(x86ild, test_668B8000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ax, word ptr [rax] */ EXPECT_EQ(7, ild(u"fïÇ    ")); } TEST(x86ild, test_668B9500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov dx, word ptr [rbp] */ EXPECT_EQ(7, ild(u"fïò    ")); } TEST(x86ild, test_5D) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop rbp */ EXPECT_EQ(1, ild(u"]")); } TEST(x86ild, test_55) { /* ICLASS: PUSH CATEGORY: PUSH EXTENSION: BASE IFORM: PUSH_GPRv_50 ISA_SET: I86 SHORT: push rbp */ EXPECT_EQ(1, ild(u"U")); } TEST(x86ild, test_89C8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, ecx */ EXPECT_EQ(2, ild(u"ë╚")); } TEST(x86ild, test_8B0CD500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rdx*8] */ EXPECT_EQ(7, ild(u"ï♀╒    ")); } TEST(x86ild, test_8A4F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rdi] */ EXPECT_EQ(3, ild(u"èO ")); } TEST(x86ild, test_8B148500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rax*4] */ EXPECT_EQ(7, ild(u"ï¶à    ")); } TEST(x86ild, test_8A5300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rbx] */ EXPECT_EQ(3, ild(u"èS ")); } TEST(x86ild, test_884F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rdi], cl */ EXPECT_EQ(3, ild(u"êO ")); } TEST(x86ild, test_8B8000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rax] */ EXPECT_EQ(6, ild(u"ïÇ    ")); } TEST(x86ild, test_8B9500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rbp] */ EXPECT_EQ(6, ild(u"ïò    ")); } TEST(x86ild, test_8A5700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rdi] */ EXPECT_EQ(3, ild(u"èW ")); } TEST(x86ild, test_884300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], al */ EXPECT_EQ(3, ild(u"êC ")); } TEST(x86ild, test_884700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rdi], al */ EXPECT_EQ(3, ild(u"êG ")); } TEST(x86ild, test_8A4800) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rax] */ EXPECT_EQ(3, ild(u"èH ")); } TEST(x86ild, test_66C780000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov word ptr [rax], 0x0 */ EXPECT_EQ(9, ild(u"f╟Ç      ")); } TEST(x86ild, test_885700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rdi], dl */ EXPECT_EQ(3, ild(u"êW ")); } TEST(x86ild, test_8B5700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rdi] */ EXPECT_EQ(3, ild(u"ïW ")); } TEST(x86ild, test_48C7050000000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov qword ptr [rip], 0x0 */ EXPECT_EQ(11, ild(u"H╟♣        ")); } TEST(x86ild, test_8B4300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rbx] */ EXPECT_EQ(3, ild(u"ïC ")); } TEST(x86ild, test_E200) { /* ICLASS: LOOP CATEGORY: COND_BR EXTENSION: BASE IFORM: LOOP_RELBRb ISA_SET: I86 SHORT: loop 0x2 */ EXPECT_EQ(2, ild(u"Γ ")); } TEST(x86ild, test_8B049500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rdx*4] */ EXPECT_EQ(7, ild(u"ï♦ò    ")); } TEST(x86ild, test_89F0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, esi */ EXPECT_EQ(2, ild(u"ë≡")); } TEST(x86ild, test_668B5300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov dx, word ptr [rbx] */ EXPECT_EQ(4, ild(u"fïS ")); } TEST(x86ild, test_8B7700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov esi, dword ptr [rdi] */ EXPECT_EQ(3, ild(u"ïw ")); } TEST(x86ild, test_66897700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rdi], si */ EXPECT_EQ(4, ild(u"fëw ")); } TEST(x86ild, test_66894300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rbx], ax */ EXPECT_EQ(4, ild(u"fëC ")); } TEST(x86ild, test_8902) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdx], eax */ EXPECT_EQ(2, ild(u"ë☻")); } TEST(x86ild, test_408A7000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov sil, byte ptr [rax] */ EXPECT_EQ(4, ild(u"@èp ")); } TEST(x86ild, test_88C2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dl, al */ EXPECT_EQ(2, ild(u"ê┬")); } TEST(x86ild, test_668B14AD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov dx, word ptr [rbp*4] */ EXPECT_EQ(8, ild(u"fﶡ    ")); } TEST(x86ild, test_668B4300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ax, word ptr [rbx] */ EXPECT_EQ(4, ild(u"fïC ")); } TEST(x86ild, test_4088CE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov sil, cl */ EXPECT_EQ(3, ild(u"@ê╬")); } TEST(x86ild, test_89C1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ecx, eax */ EXPECT_EQ(2, ild(u"ë┴")); } TEST(x86ild, test_8B14D500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rdx*8] */ EXPECT_EQ(7, ild(u"ï¶╒    ")); } TEST(x86ild, test_8B149500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rdx*4] */ EXPECT_EQ(7, ild(u"ï¶ò    ")); } TEST(x86ild, test_884B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], cl */ EXPECT_EQ(3, ild(u"êK ")); } TEST(x86ild, test_488B4700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"HïG ")); } TEST(x86ild, test_8B4F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rdi] */ EXPECT_EQ(3, ild(u"ïO ")); } TEST(x86ild, test_8A08) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rax] */ EXPECT_EQ(2, ild(u"è◘")); } TEST(x86ild, test_668B5700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov dx, word ptr [rdi] */ EXPECT_EQ(4, ild(u"fïW ")); } TEST(x86ild, test_C6470000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rdi], 0x0 */ EXPECT_EQ(4, ild(u"╞G  ")); } TEST(x86ild, test_66895700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rdi], dx */ EXPECT_EQ(4, ild(u"fëW ")); } TEST(x86ild, test_FF24D500000000) { /* ICLASS: JMP CATEGORY: UNCOND_BR EXTENSION: BASE IFORM: JMP_MEMv ISA_SET: I86 SHORT: jmp qword ptr [rdx*8] */ EXPECT_EQ(7, ild(u"λ$╒    ")); } TEST(x86ild, test_8A4B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rbx] */ EXPECT_EQ(3, ild(u"èK ")); } TEST(x86ild, test_7200) { /* ICLASS: JB CATEGORY: COND_BR EXTENSION: BASE IFORM: JB_RELBRb ISA_SET: I86 SHORT: jb 0x2 */ EXPECT_EQ(2, ild(u"r ")); } TEST(x86ild, test_88C1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov cl, al */ EXPECT_EQ(2, ild(u"ê┴")); } TEST(x86ild, test_668B14D500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov dx, word ptr [rdx*8] */ EXPECT_EQ(8, ild(u"fï¶╒    ")); } TEST(x86ild, test_8A4000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rax] */ EXPECT_EQ(3, ild(u"è@ ")); } TEST(x86ild, test_C6430000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rbx], 0x0 */ EXPECT_EQ(4, ild(u"╞C  ")); } TEST(x86ild, test_8B14ED00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rbp*8] */ EXPECT_EQ(7, ild(u"ï¶φ    ")); } TEST(x86ild, test_668B14ED00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov dx, word ptr [rbp*8] */ EXPECT_EQ(8, ild(u"fï¶φ    ")); } TEST(x86ild, test_408A7300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov sil, byte ptr [rbx] */ EXPECT_EQ(4, ild(u"@ès ")); } TEST(x86ild, test_7800) { /* ICLASS: JS CATEGORY: COND_BR EXTENSION: BASE IFORM: JS_RELBRb ISA_SET: I86 SHORT: js 0x2 */ EXPECT_EQ(2, ild(u"x ")); } TEST(x86ild, test_40887300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], sil */ EXPECT_EQ(4, ild(u"@ês ")); } TEST(x86ild, test_48890500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rip], rax */ EXPECT_EQ(7, ild(u"Hë♣    ")); } TEST(x86ild, test_B900000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov ecx, 0x0 */ EXPECT_EQ(5, ild(u"╣    ")); } TEST(x86ild, test_8B742400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov esi, dword ptr [rsp] */ EXPECT_EQ(4, ild(u"ït$ ")); } TEST(x86ild, test_89F2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edx, esi */ EXPECT_EQ(2, ild(u"ë≥")); } TEST(x86ild, test_4088F7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dil, sil */ EXPECT_EQ(3, ild(u"@ê≈")); } TEST(x86ild, test_668B942D00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov dx, word ptr [rbp+rbp*1] */ EXPECT_EQ(8, ild(u"fïö-    ")); } TEST(x86ild, test_408A7700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov sil, byte ptr [rdi] */ EXPECT_EQ(4, ild(u"@èw ")); } TEST(x86ild, test_89742400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rsp], esi */ EXPECT_EQ(4, ild(u"ët$ ")); } TEST(x86ild, test_4889EF) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdi, rbp */ EXPECT_EQ(3, ild(u"Hë∩")); } TEST(x86ild, test_7900) { /* ICLASS: JNS CATEGORY: COND_BR EXTENSION: BASE IFORM: JNS_RELBRb ISA_SET: I86 SHORT: jns 0x2 */ EXPECT_EQ(2, ild(u"y ")); } TEST(x86ild, test_89FF) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edi, edi */ EXPECT_EQ(2, ild(u"ëλ")); } TEST(x86ild, test_89CE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov esi, ecx */ EXPECT_EQ(2, ild(u"ë╬")); } TEST(x86ild, test_7600) { /* ICLASS: JBE CATEGORY: COND_BR EXTENSION: BASE IFORM: JBE_RELBRb ISA_SET: I86 SHORT: jbe 0x2 */ EXPECT_EQ(2, ild(u"v ")); } TEST(x86ild, test_4889C6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, rax */ EXPECT_EQ(3, ild(u"Hë╞")); } TEST(x86ild, test_8B048500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rax*4] */ EXPECT_EQ(7, ild(u"ï♦à    ")); } TEST(x86ild, test_415C) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop r12 */ EXPECT_EQ(2, ild(u"A\\")); } TEST(x86ild, test_488B04C500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rax*8] */ EXPECT_EQ(8, ild(u"Hï♦┼    ")); } TEST(x86ild, test_885300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], dl */ EXPECT_EQ(3, ild(u"êS ")); } TEST(x86ild, test_4889FD) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbp, rdi */ EXPECT_EQ(3, ild(u"Hë²")); } TEST(x86ild, test_4088F0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov al, sil */ EXPECT_EQ(3, ild(u"@ê≡")); } TEST(x86ild, test_89442400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rsp], eax */ EXPECT_EQ(4, ild(u"ëD$ ")); } TEST(x86ild, test_894300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rbx], eax */ EXPECT_EQ(3, ild(u"ëC ")); } TEST(x86ild, test_88D0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov al, dl */ EXPECT_EQ(2, ild(u"ê╨")); } TEST(x86ild, test_4154) { /* ICLASS: PUSH CATEGORY: PUSH EXTENSION: BASE IFORM: PUSH_GPRv_50 ISA_SET: I86 SHORT: push r12 */ EXPECT_EQ(2, ild(u"AT")); } TEST(x86ild, test_7300) { /* ICLASS: JNB CATEGORY: COND_BR EXTENSION: BASE IFORM: JNB_RELBRb ISA_SET: I86 SHORT: jnb 0x2 */ EXPECT_EQ(2, ild(u"s ")); } TEST(x86ild, test_448A4700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov r8b, byte ptr [rdi] */ EXPECT_EQ(4, ild(u"DèG ")); } TEST(x86ild, test_89F7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edi, esi */ EXPECT_EQ(2, ild(u"ë≈")); } TEST(x86ild, test_89C0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, eax */ EXPECT_EQ(2, ild(u"ë└")); } TEST(x86ild, test_668B4F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov cx, word ptr [rdi] */ EXPECT_EQ(4, ild(u"fïO ")); } TEST(x86ild, test_BB00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov ebx, 0x0 */ EXPECT_EQ(5, ild(u"╗    ")); } TEST(x86ild, test_88C8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov al, cl */ EXPECT_EQ(2, ild(u"ê╚")); } TEST(x86ild, test_66894F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rdi], cx */ EXPECT_EQ(4, ild(u"fëO ")); } TEST(x86ild, test_415D) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop r13 */ EXPECT_EQ(2, ild(u"A]")); } TEST(x86ild, test_FFE0) { /* ICLASS: JMP CATEGORY: UNCOND_BR EXTENSION: BASE IFORM: JMP_GPRv ISA_SET: I86 SHORT: jmp rax */ EXPECT_EQ(2, ild(u"λα")); } TEST(x86ild, test_FFD2) { /* ICLASS: CALL_NEAR CATEGORY: CALL EXTENSION: BASE IFORM: CALL_NEAR_GPRv ISA_SET: I86 SHORT: call rdx */ EXPECT_EQ(2, ild(u"λ╥")); } TEST(x86ild, test_FF24C500000000) { /* ICLASS: JMP CATEGORY: UNCOND_BR EXTENSION: BASE IFORM: JMP_MEMv ISA_SET: I86 SHORT: jmp qword ptr [rax*8] */ EXPECT_EQ(7, ild(u"λ$┼    ")); } TEST(x86ild, test_E000) { /* ICLASS: LOOPNE CATEGORY: COND_BR EXTENSION: BASE IFORM: LOOPNE_RELBRb ISA_SET: I86 SHORT: loopne 0x2 */ EXPECT_EQ(2, ild(u"α ")); } TEST(x86ild, test_8B4000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rax] */ EXPECT_EQ(3, ild(u"ï@ ")); } TEST(x86ild, test_89D1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ecx, edx */ EXPECT_EQ(2, ild(u"ë╤")); } TEST(x86ild, test_8B14AD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rbp*4] */ EXPECT_EQ(7, ild(u"ﶡ    ")); } TEST(x86ild, test_895700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdi], edx */ EXPECT_EQ(3, ild(u"ëW ")); } TEST(x86ild, test_488B5700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"HïW ")); } TEST(x86ild, test_4155) { /* ICLASS: PUSH CATEGORY: PUSH EXTENSION: BASE IFORM: PUSH_GPRv_50 ISA_SET: I86 SHORT: push r13 */ EXPECT_EQ(2, ild(u"AU")); } TEST(x86ild, test_668B840000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ax, word ptr [rax+rax*1] */ EXPECT_EQ(8, ild(u"fïä     ")); } TEST(x86ild, test_488B8000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rax] */ EXPECT_EQ(7, ild(u"HïÇ    ")); } TEST(x86ild, test_488B4B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rcx, qword ptr [rbx] */ EXPECT_EQ(4, ild(u"HïK ")); } TEST(x86ild, test_0F8700000000) { /* ICLASS: JNBE CATEGORY: COND_BR EXTENSION: BASE IFORM: JNBE_RELBRd ISA_SET: I86 SHORT: jnbe 0x6 */ EXPECT_EQ(6, ild(u"☼ç    ")); } TEST(x86ild, test_8B5300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rbx] */ EXPECT_EQ(3, ild(u"ïS ")); } TEST(x86ild, test_668B048500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ax, word ptr [rax*4] */ EXPECT_EQ(8, ild(u"fï♦à    ")); } TEST(x86ild, test_66898100000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rcx], ax */ EXPECT_EQ(7, ild(u"fëü    ")); } TEST(x86ild, test_488B17) { /* ICLASS: MOV CATEGORY: DATAXFER g EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rdi] */ EXPECT_EQ(3, ild(u"Hï↨")); } TEST(x86ild, test_4889C2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdx, rax */ EXPECT_EQ(3, ild(u"Hë┬")); } TEST(x86ild, test_C7400000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov dword ptr [rax], 0x0 */ EXPECT_EQ(7, ild(u"╟@     ")); } TEST(x86ild, test_4C89E7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdi, r12 */ EXPECT_EQ(3, ild(u"Lëτ")); } TEST(x86ild, test_488B3B) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdi, qword ptr [rbx] */ EXPECT_EQ(3, ild(u"Hï;")); } TEST(x86ild, test_4889EE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, rbp */ EXPECT_EQ(3, ild(u"Hëε")); } TEST(x86ild, test_4488C0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov al, r8b */ EXPECT_EQ(3, ild(u"Dê└")); } TEST(x86ild, test_415E) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop r14 */ EXPECT_EQ(2, ild(u"A^")); } TEST(x86ild, test_4156) { /* ICLASS: PUSH CATEGORY: PUSH EXTENSION: BASE IFORM: PUSH_GPRv_50 ISA_SET: I86 SHORT: push r14 */ EXPECT_EQ(2, ild(u"AV")); } TEST(x86ild, test_8B542400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rsp] */ EXPECT_EQ(4, ild(u"ïT$ ")); } TEST(x86ild, test_89C7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edi, eax */ EXPECT_EQ(2, ild(u"ë╟")); } TEST(x86ild, test_488B8700000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rdi] */ EXPECT_EQ(7, ild(u"Hïç    ")); } TEST(x86ild, test_448A4F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov r9b, byte ptr [rdi] */ EXPECT_EQ(4, ild(u"DèO ")); } TEST(x86ild, test_408A30) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov sil, byte ptr [rax] */ EXPECT_EQ(3, ild(u"@è0")); } TEST(x86ild, test_4189C6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r14d, eax */ EXPECT_EQ(3, ild(u"Aë╞")); } TEST(x86ild, test_897300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rbx], esi */ EXPECT_EQ(3, ild(u"ës ")); } TEST(x86ild, test_894F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdi], ecx */ EXPECT_EQ(3, ild(u"ëO ")); } TEST(x86ild, test_4489E6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov esi, r12d */ EXPECT_EQ(3, ild(u"Dëμ")); } TEST(x86ild, test_4488C8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov al, r9b */ EXPECT_EQ(3, ild(u"Dê╚")); } TEST(x86ild, test_8A10) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rax] */ EXPECT_EQ(2, ild(u"è►")); } TEST(x86ild, test_894200) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdx], eax */ EXPECT_EQ(3, ild(u"ëB ")); } TEST(x86ild, test_88D1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov cl, dl */ EXPECT_EQ(2, ild(u"ê╤")); } TEST(x86ild, test_58) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop rax */ EXPECT_EQ(1, ild(u"X")); } TEST(x86ild, test_48B90000000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov rcx, 0x0 */ EXPECT_EQ(10, ild(u"H╣        ")); } TEST(x86ild, test_488B14D500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rdx*8] */ EXPECT_EQ(8, ild(u"Hï¶╒    ")); } TEST(x86ild, test_4489F2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edx, r14d */ EXPECT_EQ(3, ild(u"Dë≥")); } TEST(x86ild, test_4489EA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edx, r13d */ EXPECT_EQ(3, ild(u"DëΩ")); } TEST(x86ild, test_8B04BD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rdi*4] */ EXPECT_EQ(7, ild(u"ï♦╜    ")); } TEST(x86ild, test_89F1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ecx, esi */ EXPECT_EQ(2, ild(u"ë±")); } TEST(x86ild, test_488B7F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdi, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"Hï⌂ ")); } TEST(x86ild, test_4488C2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dl, r8b */ EXPECT_EQ(3, ild(u"Dê┬")); } TEST(x86ild, test_4189C4) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r12d, eax */ EXPECT_EQ(3, ild(u"Aë─")); } TEST(x86ild, test_8A049500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rdx*4] */ EXPECT_EQ(7, ild(u"è♦ò    ")); } TEST(x86ild, test_89F6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov esi, esi */ EXPECT_EQ(2, ild(u"ë÷")); } TEST(x86ild, test_89EE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov esi, ebp */ EXPECT_EQ(2, ild(u"ëε")); } TEST(x86ild, test_89DE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov esi, ebx */ EXPECT_EQ(2, ild(u"ë▐")); } TEST(x86ild, test_89DA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edx, ebx */ EXPECT_EQ(2, ild(u"ë┌")); } TEST(x86ild, test_89C3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ebx, eax */ EXPECT_EQ(2, ild(u"ë├")); } TEST(x86ild, test_7E00) { /* ICLASS: JLE CATEGORY: COND_BR EXTENSION: BASE IFORM: JLE_RELBRb ISA_SET: I86 SHORT: jle 0x2 */ EXPECT_EQ(2, ild(u"~ ")); } TEST(x86ild, test_66897300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rbx], si */ EXPECT_EQ(4, ild(u"fës ")); } TEST(x86ild, test_4889F3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbx, rsi */ EXPECT_EQ(3, ild(u"Hë≤")); } TEST(x86ild, test_4489C1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ecx, r8d */ EXPECT_EQ(3, ild(u"Dë┴")); } TEST(x86ild, test_40886B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], bpl */ EXPECT_EQ(4, ild(u"@êk ")); } TEST(x86ild, test_C7800000000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov dword ptr [rax], 0x0 */ EXPECT_EQ(10, ild(u"╟Ç        ")); } TEST(x86ild, test_C7420000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov dword ptr [rdx], 0x0 */ EXPECT_EQ(7, ild(u"╟B     ")); } TEST(x86ild, test_899000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rax], edx */ EXPECT_EQ(6, ild(u"ëÉ    ")); } TEST(x86ild, test_59) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop rcx */ EXPECT_EQ(1, ild(u"Y")); } TEST(x86ild, test_48D3E2) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_CL_D3r4 ISA_SET: I86 SHORT: shl rdx, cl */ EXPECT_EQ(3, ild(u"H╙Γ")); } TEST(x86ild, test_48C7470000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov qword ptr [rdi], 0x0 */ EXPECT_EQ(8, ild(u"H╟G     ")); } TEST(x86ild, test_488B4F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rcx, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"HïO ")); } TEST(x86ild, test_4863F6) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd rsi, esi */ EXPECT_EQ(3, ild(u"Hc÷")); } TEST(x86ild, test_4489E2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edx, r12d */ EXPECT_EQ(3, ild(u"DëΓ")); } TEST(x86ild, test_415F) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop r15 */ EXPECT_EQ(2, ild(u"A_")); } TEST(x86ild, test_4157) { /* ICLASS: PUSH CATEGORY: PUSH EXTENSION: BASE IFORM: PUSH_GPRv_50 ISA_SET: I86 SHORT: push r15 */ EXPECT_EQ(2, ild(u"AW")); } TEST(x86ild, test_408A6B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov bpl, byte ptr [rbx] */ EXPECT_EQ(4, ild(u"@èk ")); } TEST(x86ild, test_4088C6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov sil, al */ EXPECT_EQ(3, ild(u"@ê╞")); } TEST(x86ild, test_8A4600) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rsi] */ EXPECT_EQ(3, ild(u"èF ")); } TEST(x86ild, test_8A04D500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rdx*8] */ EXPECT_EQ(7, ild(u"è♦╒    ")); } TEST(x86ild, test_89F8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, edi */ EXPECT_EQ(2, ild(u"ë°")); } TEST(x86ild, test_89C6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov esi, eax */ EXPECT_EQ(2, ild(u"ë╞")); } TEST(x86ild, test_89542400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rsp], edx */ EXPECT_EQ(4, ild(u"ëT$ ")); } TEST(x86ild, test_88CA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dl, cl */ EXPECT_EQ(2, ild(u"ê╩")); } TEST(x86ild, test_4C89EF) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdi, r13 */ EXPECT_EQ(3, ild(u"Lë∩")); } TEST(x86ild, test_48C70700000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov qword ptr [rdi], 0x0 */ EXPECT_EQ(7, ild(u"H╟•    ")); } TEST(x86ild, test_48897700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rdi], rsi */ EXPECT_EQ(4, ild(u"Hëw ")); } TEST(x86ild, test_448B6C2400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r13d, dword ptr [rsp] */ EXPECT_EQ(5, ild(u"Dïl$ ")); } TEST(x86ild, test_FF24CD00000000) { /* ICLASS: JMP CATEGORY: UNCOND_BR EXTENSION: BASE IFORM: JMP_MEMv ISA_SET: I86 SHORT: jmp qword ptr [rcx*8] */ EXPECT_EQ(7, ild(u"λ$═    ")); } TEST(x86ild, test_F2AE) { /* ICLASS: REPNE_SCASB CATEGORY: STRINGOP EXTENSION: BASE IFORM: REPNE_SCASB ISA_SET: I86 SHORT: repne scasb byte ptr [rdi] */ EXPECT_EQ(2, ild(u"≥«")); } TEST(x86ild, test_E90083E000) { /* ICLASS: JMP CATEGORY: UNCOND_BR EXTENSION: BASE IFORM: JMP_RELBRd ISA_SET: I86 SHORT: jmp 0xe08305 */ EXPECT_EQ(5, ild(u"Θ âα ")); } TEST(x86ild, test_C7040700000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov dword ptr [rdi+rax*1], 0x0 */ EXPECT_EQ(7, ild(u"╟♦•    ")); } TEST(x86ild, test_C644240000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rsp], 0x0 */ EXPECT_EQ(5, ild(u"╞D$  ")); } TEST(x86ild, test_8B9200000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rdx] */ EXPECT_EQ(6, ild(u"ïÆ    ")); } TEST(x86ild, test_8B7D00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edi, dword ptr [rbp] */ EXPECT_EQ(3, ild(u"ï} ")); } TEST(x86ild, test_8A8000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rax] */ EXPECT_EQ(6, ild(u"èÇ    ")); } TEST(x86ild, test_8A5000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rax] */ EXPECT_EQ(3, ild(u"èP ")); } TEST(x86ild, test_89F5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ebp, esi */ EXPECT_EQ(2, ild(u"ë⌡")); } TEST(x86ild, test_89EA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edx, ebp */ EXPECT_EQ(2, ild(u"ëΩ")); } TEST(x86ild, test_89E8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, ebp */ EXPECT_EQ(2, ild(u"ëΦ")); } TEST(x86ild, test_668B7B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov di, word ptr [rbx] */ EXPECT_EQ(4, ild(u"fï{ ")); } TEST(x86ild, test_4989FC) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r12, rdi */ EXPECT_EQ(3, ild(u"Iëⁿ")); } TEST(x86ild, test_48D3E0) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_CL_D3r4 ISA_SET: I86 SHORT: shl rax, cl */ EXPECT_EQ(3, ild(u"H╙α")); } TEST(x86ild, test_48BE0000000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov rsi, 0x0 */ EXPECT_EQ(10, ild(u"H╛        ")); } TEST(x86ild, test_488B6F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rbp, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"Hïo ")); } TEST(x86ild, test_488B5500) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rbp] */ EXPECT_EQ(4, ild(u"HïU ")); } TEST(x86ild, test_4889E5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbp, rsp */ EXPECT_EQ(3, ild(u"Hëσ")); } TEST(x86ild, test_4889D5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbp, rdx */ EXPECT_EQ(3, ild(u"Hë╒")); } TEST(x86ild, test_448B442400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r8d, dword ptr [rsp] */ EXPECT_EQ(5, ild(u"DïD$ ")); } TEST(x86ild, test_4488C6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov sil, r8b */ EXPECT_EQ(3, ild(u"Dê╞")); } TEST(x86ild, test_4189C5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r13d, eax */ EXPECT_EQ(3, ild(u"Aë┼")); } TEST(x86ild, test_0F8D00000000) { /* ICLASS: JNL CATEGORY: COND_BR EXTENSION: BASE IFORM: JNL_RELBRd ISA_SET: I86 SHORT: jnl 0x6 */ EXPECT_EQ(6, ild(u"☼ì    ")); } TEST(x86ild, test_C6400000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rax], 0x0 */ EXPECT_EQ(4, ild(u"╞@  ")); } TEST(x86ild, test_B000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_IMMb_B0 ISA_SET: I86 SHORT: mov al, 0x0 */ EXPECT_EQ(2, ild(u"░ ")); } TEST(x86ild, test_8BB900000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edi, dword ptr [rcx] */ EXPECT_EQ(6, ild(u"ï╣    ")); } TEST(x86ild, test_8BB000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov esi, dword ptr [rax] */ EXPECT_EQ(6, ild(u"ï░    ")); } TEST(x86ild, test_8A00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rax] */ EXPECT_EQ(2, ild(u"è ")); } TEST(x86ild, test_89C5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ebp, eax */ EXPECT_EQ(2, ild(u"ë┼")); } TEST(x86ild, test_896A00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdx], ebp */ EXPECT_EQ(3, ild(u"ëj ")); } TEST(x86ild, test_8802) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rdx], al */ EXPECT_EQ(2, ild(u"ê☻")); } TEST(x86ild, test_7F00) { /* ICLASS: JNLE CATEGORY: COND_BR EXTENSION: BASE IFORM: JNLE_RELBRb ISA_SET: I86 SHORT: jnle 0x2 */ EXPECT_EQ(2, ild(u"⌂ ")); } TEST(x86ild, test_7D00) { /* ICLASS: JNL CATEGORY: COND_BR EXTENSION: BASE IFORM: JNL_RELBRb ISA_SET: I86 SHORT: jnl 0x2 */ EXPECT_EQ(2, ild(u"} ")); } TEST(x86ild, test_668B7700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov si, word ptr [rdi] */ EXPECT_EQ(4, ild(u"fïw ")); } TEST(x86ild, test_48D3EA) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_CL ISA_SET: I86 SHORT: shr rdx, cl */ EXPECT_EQ(3, ild(u"H╙Ω")); } TEST(x86ild, test_488B3D00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdi, qword ptr [rip] */ EXPECT_EQ(7, ild(u"Hï=    ")); } TEST(x86ild, test_488B14DD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rbx*8] */ EXPECT_EQ(8, ild(u"Hï¶▌    ")); } TEST(x86ild, test_488B0500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rip] */ EXPECT_EQ(7, ild(u"Hï♣    ")); } TEST(x86ild, test_4889FE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, rdi */ EXPECT_EQ(3, ild(u"Hë■")); } TEST(x86ild, test_4889D9) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rcx, rbx */ EXPECT_EQ(3, ild(u"Hë┘")); } TEST(x86ild, test_4889C8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rax, rcx */ EXPECT_EQ(3, ild(u"Hë╚")); } TEST(x86ild, test_4889C3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbx, rax */ EXPECT_EQ(3, ild(u"Hë├")); } TEST(x86ild, test_488937) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rdi], rsi */ EXPECT_EQ(3, ild(u"Hë7")); } TEST(x86ild, test_4863C9) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd rcx, ecx */ EXPECT_EQ(3, ild(u"Hc╔")); } TEST(x86ild, test_448B7C2400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r15d, dword ptr [rsp] */ EXPECT_EQ(5, ild(u"Dï|$ ")); } TEST(x86ild, test_448A5700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov r10b, byte ptr [rdi] */ EXPECT_EQ(4, ild(u"DèW ")); } TEST(x86ild, test_448A4300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov r8b, byte ptr [rbx] */ EXPECT_EQ(4, ild(u"DèC ")); } TEST(x86ild, test_4488D2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dl, r10b */ EXPECT_EQ(3, ild(u"Dê╥")); } TEST(x86ild, test_4488C9) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov cl, r9b */ EXPECT_EQ(3, ild(u"Dê╔")); } TEST(x86ild, test_41BC00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov r12d, 0x0 */ EXPECT_EQ(6, ild(u"A╝    ")); } TEST(x86ild, test_4189F5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r13d, esi */ EXPECT_EQ(3, ild(u"Aë⌡")); } TEST(x86ild, test_40887700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rdi], sil */ EXPECT_EQ(4, ild(u"@êw ")); } TEST(x86ild, test_decode) { /* */ EXPECT_EQ(2, ild(u"▐═")); } TEST(x86ild, test_D3E0) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_CL_D3r4 ISA_SET: I86 SHORT: shl eax, cl */ EXPECT_EQ(2, ild(u"╙α")); } TEST(x86ild, test_BD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov ebp, 0x0 */ EXPECT_EQ(5, ild(u"╜    ")); } TEST(x86ild, test_8B4B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rbx] */ EXPECT_EQ(3, ild(u"ïK ")); } TEST(x86ild, test_8B07) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rdi] */ EXPECT_EQ(2, ild(u"ï•")); } TEST(x86ild, test_8A9000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rax] */ EXPECT_EQ(6, ild(u"èÉ    ")); } TEST(x86ild, test_8A4A00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rdx] */ EXPECT_EQ(3, ild(u"èJ ")); } TEST(x86ild, test_8A4500) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rbp] */ EXPECT_EQ(3, ild(u"èE ")); } TEST(x86ild, test_8A14D500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rdx*8] */ EXPECT_EQ(7, ild(u"è¶╒    ")); } TEST(x86ild, test_8A0CD500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rdx*8] */ EXPECT_EQ(7, ild(u"è♀╒    ")); } TEST(x86ild, test_8A0C08) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rax+rcx*1] */ EXPECT_EQ(3, ild(u"è♀◘")); } TEST(x86ild, test_89D6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov esi, edx */ EXPECT_EQ(2, ild(u"ë╓")); } TEST(x86ild, test_89D5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ebp, edx */ EXPECT_EQ(2, ild(u"ë╒")); } TEST(x86ild, test_897700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdi], esi */ EXPECT_EQ(3, ild(u"ëw ")); } TEST(x86ild, test_895A00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdx], ebx */ EXPECT_EQ(3, ild(u"ëZ ")); } TEST(x86ild, test_895000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rax], edx */ EXPECT_EQ(3, ild(u"ëP ")); } TEST(x86ild, test_8910) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rax], edx */ EXPECT_EQ(2, ild(u"ë►")); } TEST(x86ild, test_7C00) { /* ICLASS: JL CATEGORY: COND_BR EXTENSION: BASE IFORM: JL_RELBRb ISA_SET: I86 SHORT: jl 0x2 */ EXPECT_EQ(2, ild(u"| ")); } TEST(x86ild, test_4C89C1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rcx, r8 */ EXPECT_EQ(3, ild(u"Lë┴")); } TEST(x86ild, test_498B5500) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [r13] */ EXPECT_EQ(4, ild(u"IïU ")); } TEST(x86ild, test_4989D5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r13, rdx */ EXPECT_EQ(3, ild(u"Ië╒")); } TEST(x86ild, test_48D3E8) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_CL ISA_SET: I86 SHORT: shr rax, cl */ EXPECT_EQ(3, ild(u"H╙Φ")); } TEST(x86ild, test_48C7430000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov qword ptr [rbx], 0x0 */ EXPECT_EQ(8, ild(u"H╟C     ")); } TEST(x86ild, test_4898) { /* ICLASS: CDQE CATEGORY: CONVERT EXTENSION: LONGMODE IFORM: CDQE ISA_SET: LONGMODE SHORT: cdqe */ EXPECT_EQ(2, ild(u"Hÿ")); } TEST(x86ild, test_488B9600000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rsi] */ EXPECT_EQ(7, ild(u"Hïû    ")); } TEST(x86ild, test_488B0B) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rcx, qword ptr [rbx] */ EXPECT_EQ(3, ild(u"Hï♂")); } TEST(x86ild, test_4889F7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdi, rsi */ EXPECT_EQ(3, ild(u"Hë≈")); } TEST(x86ild, test_4889F5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbp, rsi */ EXPECT_EQ(3, ild(u"Hë⌡")); } TEST(x86ild, test_4889F0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rax, rsi */ EXPECT_EQ(3, ild(u"Hë≡")); } TEST(x86ild, test_4889DE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, rbx */ EXPECT_EQ(3, ild(u"Hë▐")); } TEST(x86ild, test_4889D1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rcx, rdx */ EXPECT_EQ(3, ild(u"Hë╤")); } TEST(x86ild, test_4889CE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, rcx */ EXPECT_EQ(3, ild(u"Hë╬")); } TEST(x86ild, test_4889C7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdi, rax */ EXPECT_EQ(3, ild(u"Hë╟")); } TEST(x86ild, test_48893D00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rip], rdi */ EXPECT_EQ(7, ild(u"Hë=    ")); } TEST(x86ild, test_48893500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rip], rsi */ EXPECT_EQ(7, ild(u"Hë5    ")); } TEST(x86ild, test_48891500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rip], rdx */ EXPECT_EQ(7, ild(u"H맠   ")); } TEST(x86ild, test_488903) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rbx], rax */ EXPECT_EQ(3, ild(u"Hë♥")); } TEST(x86ild, test_4489FF) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edi, r15d */ EXPECT_EQ(3, ild(u"Dëλ")); }
65,637
3,706
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_lib.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/bing.internal.h" #include "libc/macros.internal.h" #include "libc/mem/gc.internal.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" dontdiscard uint8_t *unbingx86op(const char16_t *codez) { size_t len; len = strlen16(codez); return unbingbuf(xmalloc(ROUNDUP(len, 16)), len, codez, 0x90); } /** * Long mode instruction length decoder. */ int ild(const char16_t *codez) { int error; struct XedDecodedInst xedd; error = xed_instruction_length_decode( xed_decoded_inst_zero_set_mode(&xedd, XED_MACHINE_MODE_LONG_64), gc(unbingx86op(codez)), strlen16(codez) + 16); return error == XED_ERROR_NONE ? xedd.length : -error; } /** * Real mode instruction length decoder. */ int ildreal(const char16_t *codez) { int error; struct XedDecodedInst xedd; error = xed_instruction_length_decode( xed_decoded_inst_zero_set_mode(&xedd, XED_MACHINE_MODE_REAL), gc(unbingx86op(codez)), strlen16(codez) + 16); return error == XED_ERROR_NONE ? xedd.length : -error; } /** * Legacy mode instruction length decoder. */ int ildlegacy(const char16_t *codez) { int error; struct XedDecodedInst xedd; error = xed_instruction_length_decode( xed_decoded_inst_zero_set_mode(&xedd, XED_MACHINE_MODE_LEGACY_32), gc(unbingx86op(codez)), strlen16(codez) + 16); return error == XED_ERROR_NONE ? xedd.length : -error; }
3,312
69
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_popular_cmov_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" TEST(x86ild, test_0F45C2) { /* ICLASS: CMOVNZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVNZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovnz eax, edx */ ASSERT_EQ(3, ild(u"☼E┬")); } TEST(x86ild, test_0F47F8) { /* ICLASS: CMOVNBE CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVNBE_GPRv_GPRv ISA_SET: CMOV SHORT: cmovnbe edi, eax */ ASSERT_EQ(3, ild(u"☼G°")); } TEST(x86ild, test_480F44F0) { /* ICLASS: CMOVZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovz rsi, rax */ ASSERT_EQ(4, ild(u"H☼D≡")); } TEST(x86ild, test_0F44C2) { /* ICLASS: CMOVZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovz eax, edx */ ASSERT_EQ(3, ild(u"☼D┬")); } TEST(x86ild, test_0F47E8) { /* ICLASS: CMOVNBE CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVNBE_GPRv_GPRv ISA_SET: CMOV SHORT: cmovnbe ebp, eax */ ASSERT_EQ(3, ild(u"☼GΦ")); } TEST(x86ild, test_0F45C3) { /* ICLASS: CMOVNZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVNZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovnz eax, ebx */ ASSERT_EQ(3, ild(u"☼E├")); } TEST(x86ild, test_0F44C7) { /* ICLASS: CMOVZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovz eax, edi */ ASSERT_EQ(3, ild(u"☼D╟")); } TEST(x86ild, test_480F44F2) { /* ICLASS: CMOVZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovz rsi, rdx */ ASSERT_EQ(4, ild(u"H☼D≥")); } TEST(x86ild, test_480F44C7) { /* ICLASS: CMOVZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovz rax, rdi */ ASSERT_EQ(4, ild(u"H☼D╟")); } TEST(x86ild, test_440F45F2) { /* ICLASS: CMOVNZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVNZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovnz r14d, edx */ ASSERT_EQ(4, ild(u"D☼E≥")); } TEST(x86ild, test_440F45F0) { /* ICLASS: CMOVNZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVNZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovnz r14d, eax */ ASSERT_EQ(4, ild(u"D☼E≡")); } TEST(x86ild, test_0F4DC8) { /* ICLASS: CMOVNL CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVNL_GPRv_GPRv ISA_SET: CMOV SHORT: cmovnl ecx, eax */ ASSERT_EQ(3, ild(u"☼M╚")); } TEST(x86ild, test_0F46D8) { /* ICLASS: CMOVBE CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVBE_GPRv_GPRv ISA_SET: CMOV SHORT: cmovbe ebx, eax */ ASSERT_EQ(3, ild(u"☼F╪")); } TEST(x86ild, test_0F46CF) { /* ICLASS: CMOVBE CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVBE_GPRv_GPRv ISA_SET: CMOV SHORT: cmovbe ecx, edi */ ASSERT_EQ(3, ild(u"☼F╧")); } TEST(x86ild, test_0F46C1) { /* ICLASS: CMOVBE CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVBE_GPRv_GPRv ISA_SET: CMOV SHORT: cmovbe eax, ecx */ ASSERT_EQ(3, ild(u"☼F┴")); } TEST(x86ild, test_0F45C6) { /* ICLASS: CMOVNZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVNZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovnz eax, esi */ ASSERT_EQ(3, ild(u"☼E╞")); } TEST(x86ild, test_0F44D0) { /* ICLASS: CMOVZ CATEGORY: CMOV EXTENSION: BASE IFORM: CMOVZ_GPRv_GPRv ISA_SET: CMOV SHORT: cmovz edx, eax */ ASSERT_EQ(3, ild(u"☼D╨")); }
5,422
226
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_popular_logical_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" TEST(x86ild, test_85C0) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test eax, eax */ ASSERT_EQ(2, ild(u"à└")); } TEST(x86ild, test_31D2) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor edx, edx */ ASSERT_EQ(2, ild(u"1╥")); } TEST(x86ild, test_81E600000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and esi, 0x0 */ ASSERT_EQ(6, ild(u"üμ    ")); } TEST(x86ild, test_31C0) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor eax, eax */ ASSERT_EQ(2, ild(u"1└")); } TEST(x86ild, test_83E100) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and ecx, 0x0 */ ASSERT_EQ(3, ild(u"âß ")); } TEST(x86ild, test_83E000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and eax, 0x0 */ ASSERT_EQ(3, ild(u"âα ")); } TEST(x86ild, test_83E200) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and edx, 0x0 */ ASSERT_EQ(3, ild(u"âΓ ")); } TEST(x86ild, test_F6430000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMb_IMMb_F6r0 ISA_SET: I86 SHORT: test byte ptr [rbx], 0x0 */ ASSERT_EQ(4, ild(u"÷C  ")); } TEST(x86ild, test_66250000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_OrAX_IMMz ISA_SET: I86 SHORT: and ax, 0x0 */ ASSERT_EQ(4, ild(u"f%  ")); } TEST(x86ild, test_2500000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_OrAX_IMMz ISA_SET: I86 SHORT: and eax, 0x0 */ ASSERT_EQ(5, ild(u"%    ")); } TEST(x86ild, test_09D0) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or eax, edx */ ASSERT_EQ(2, ild(u"○╨")); } TEST(x86ild, test_48234300) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_MEMv ISA_SET: I86 SHORT: and rax, qword ptr [rbx] */ ASSERT_EQ(4, ild(u"H#C ")); } TEST(x86ild, test_83C800) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_IMMb ISA_SET: I86 SHORT: or eax, 0x0 */ ASSERT_EQ(3, ild(u"â╚ ")); } TEST(x86ild, test_0C00) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_AL_IMMb ISA_SET: I86 SHORT: or al, 0x0 */ ASSERT_EQ(2, ild(u"♀ ")); } TEST(x86ild, test_31C9) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor ecx, ecx */ ASSERT_EQ(2, ild(u"1╔")); } TEST(x86ild, test_804F0000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_MEMb_IMMb_80r1 ISA_SET: I86 SHORT: or byte ptr [rdi], 0x0 */ ASSERT_EQ(4, ild(u"ÇO  ")); } TEST(x86ild, test_09F1) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or ecx, esi */ ASSERT_EQ(2, ild(u"○±")); } TEST(x86ild, test_6681E20000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and dx, 0x0 */ ASSERT_EQ(5, ild(u"füΓ  ")); } TEST(x86ild, test_09C8) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or eax, ecx */ ASSERT_EQ(2, ild(u"○╚")); } TEST(x86ild, test_83E600) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and esi, 0x0 */ ASSERT_EQ(3, ild(u"âμ ")); } TEST(x86ild, test_80CC00) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPR8_IMMb_80r1 ISA_SET: I86 SHORT: or ah, 0x0 */ ASSERT_EQ(3, ild(u"Ç╠ ")); } TEST(x86ild, test_09C2) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or edx, eax */ ASSERT_EQ(2, ild(u"○┬")); } TEST(x86ild, test_6681E60000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and si, 0x0 */ ASSERT_EQ(5, ild(u"füμ  ")); } TEST(x86ild, test_660D0000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_OrAX_IMMz ISA_SET: I86 SHORT: or ax, 0x0 */ ASSERT_EQ(4, ild(u"f♪  ")); } TEST(x86ild, test_09C6) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or esi, eax */ ASSERT_EQ(2, ild(u"○╞")); } TEST(x86ild, test_83CA00) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_IMMb ISA_SET: I86 SHORT: or edx, 0x0 */ ASSERT_EQ(3, ild(u"â╩ ")); } TEST(x86ild, test_6681E10000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and cx, 0x0 */ ASSERT_EQ(5, ild(u"füß  ")); } TEST(x86ild, test_80E200) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPR8_IMMb_80r4 ISA_SET: I86 SHORT: and dl, 0x0 */ ASSERT_EQ(3, ild(u"ÇΓ ")); } TEST(x86ild, test_09FE) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or esi, edi */ ASSERT_EQ(2, ild(u"○■")); } TEST(x86ild, test_F6470000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMb_IMMb_F6r0 ISA_SET: I86 SHORT: test byte ptr [rdi], 0x0 */ ASSERT_EQ(4, ild(u"÷G  ")); } TEST(x86ild, test_4885C0) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test rax, rax */ ASSERT_EQ(3, ild(u"Hà└")); } TEST(x86ild, test_83F200) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_IMMb ISA_SET: I86 SHORT: xor edx, 0x0 */ ASSERT_EQ(3, ild(u"â≥ ")); } TEST(x86ild, test_0D00000000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_OrAX_IMMz ISA_SET: I86 SHORT: or eax, 0x0 */ ASSERT_EQ(5, ild(u"♪    ")); } TEST(x86ild, test_84C0) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPR8_GPR8 ISA_SET: I86 SHORT: test al, al */ ASSERT_EQ(2, ild(u"ä└")); } TEST(x86ild, test_A800) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_AL_IMMb ISA_SET: I86 SHORT: test al, 0x0 */ ASSERT_EQ(2, ild(u"¿ ")); } TEST(x86ild, test_81E200000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and edx, 0x0 */ ASSERT_EQ(6, ild(u"üΓ    ")); } TEST(x86ild, test_F6450000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMb_IMMb_F6r0 ISA_SET: I86 SHORT: test byte ptr [rbp], 0x0 */ ASSERT_EQ(4, ild(u"÷E  ")); } TEST(x86ild, test_80670000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_MEMb_IMMb_80r4 ISA_SET: I86 SHORT: and byte ptr [rdi], 0x0 */ ASSERT_EQ(4, ild(u"Çg  ")); } TEST(x86ild, test_4885D2) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test rdx, rdx */ ASSERT_EQ(3, ild(u"Hà╥")); } TEST(x86ild, test_83F100) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_IMMb ISA_SET: I86 SHORT: xor ecx, 0x0 */ ASSERT_EQ(3, ild(u"â± ")); } TEST(x86ild, test_81E100000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and ecx, 0x0 */ ASSERT_EQ(6, ild(u"üß    ")); } TEST(x86ild, test_80E100) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPR8_IMMb_80r4 ISA_SET: I86 SHORT: and cl, 0x0 */ ASSERT_EQ(3, ild(u"Çß ")); } TEST(x86ild, test_84D2) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPR8_GPR8 ISA_SET: I86 SHORT: test dl, dl */ ASSERT_EQ(2, ild(u"ä╥")); } TEST(x86ild, test_6681CA0000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_IMMz ISA_SET: I86 SHORT: or dx, 0x0 */ ASSERT_EQ(5, ild(u"fü╩  ")); } TEST(x86ild, test_09C1) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or ecx, eax */ ASSERT_EQ(2, ild(u"○┴")); } TEST(x86ild, test_804B0000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_MEMb_IMMb_80r1 ISA_SET: I86 SHORT: or byte ptr [rbx], 0x0 */ ASSERT_EQ(4, ild(u"ÇK  ")); } TEST(x86ild, test_4885FF) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test rdi, rdi */ ASSERT_EQ(3, ild(u"Hàλ")); } TEST(x86ild, test_85F6) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test esi, esi */ ASSERT_EQ(2, ild(u"à÷")); } TEST(x86ild, test_4585ED) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test r13d, r13d */ ASSERT_EQ(3, ild(u"Eàφ")); } TEST(x86ild, test_84C9) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPR8_GPR8 ISA_SET: I86 SHORT: test cl, cl */ ASSERT_EQ(2, ild(u"ä╔")); } TEST(x86ild, test_83F000) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_IMMb ISA_SET: I86 SHORT: xor eax, 0x0 */ ASSERT_EQ(3, ild(u"â≡ ")); } TEST(x86ild, test_09F2) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or edx, esi */ ASSERT_EQ(2, ild(u"○≥")); } TEST(x86ild, test_4183E000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and r8d, 0x0 */ ASSERT_EQ(4, ild(u"Aâα ")); } TEST(x86ild, test_85D2) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test edx, edx */ ASSERT_EQ(2, ild(u"à╥")); } TEST(x86ild, test_83E700) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and edi, 0x0 */ ASSERT_EQ(3, ild(u"âτ ")); } TEST(x86ild, test_31F6) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor esi, esi */ ASSERT_EQ(2, ild(u"1÷")); } TEST(x86ild, test_668167000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_MEMv_IMMz ISA_SET: I86 SHORT: and word ptr [rdi], 0x0 */ ASSERT_EQ(6, ild(u"füg   ")); } TEST(x86ild, test_09F0) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or eax, esi */ ASSERT_EQ(2, ild(u"○≡")); } TEST(x86ild, test_81E700000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and edi, 0x0 */ ASSERT_EQ(6, ild(u"üτ    ")); } TEST(x86ild, test_66F743000000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMv_IMMz_F7r0 ISA_SET: I86 SHORT: test word ptr [rbx], 0x0 */ ASSERT_EQ(6, ild(u"f≈C   ")); } TEST(x86ild, test_40F6C500) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPR8_IMMb_F6r0 ISA_SET: I86 SHORT: test bpl, 0x0 */ ASSERT_EQ(4, ild(u"@÷┼ ")); } TEST(x86ild, test_80CA00) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPR8_IMMb_80r1 ISA_SET: I86 SHORT: or dl, 0x0 */ ASSERT_EQ(3, ild(u"Ç╩ ")); } TEST(x86ild, test_48235300) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_MEMv ISA_SET: I86 SHORT: and rdx, qword ptr [rbx] */ ASSERT_EQ(4, ild(u"H#S ")); } TEST(x86ild, test_31DB) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor ebx, ebx */ ASSERT_EQ(2, ild(u"1█")); } TEST(x86ild, test_25000083E2) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_OrAX_IMMz ISA_SET: I86 SHORT: and eax, 0xe2830000 */ ASSERT_EQ(5, ild(u"%  âΓ")); } TEST(x86ild, test_24D5) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_AL_IMMb ISA_SET: I86 SHORT: and al, 0xd5 */ ASSERT_EQ(2, ild(u"$╒")); } TEST(x86ild, test_F6C200) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPR8_IMMb_F6r0 ISA_SET: I86 SHORT: test dl, 0x0 */ ASSERT_EQ(3, ild(u"÷┬ ")); } TEST(x86ild, test_80630000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_MEMb_IMMb_80r4 ISA_SET: I86 SHORT: and byte ptr [rbx], 0x0 */ ASSERT_EQ(4, ild(u"Çc  ")); } TEST(x86ild, test_4409D0) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or eax, r10d */ ASSERT_EQ(3, ild(u"D○╨")); } TEST(x86ild, test_4409C0) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or eax, r8d */ ASSERT_EQ(3, ild(u"D○└")); } TEST(x86ild, test_4183F000) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_IMMb ISA_SET: I86 SHORT: xor r8d, 0x0 */ ASSERT_EQ(4, ild(u"Aâ≡ ")); } TEST(x86ild, test_40F6C600) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPR8_IMMb_F6r0 ISA_SET: I86 SHORT: test sil, 0x0 */ ASSERT_EQ(4, ild(u"@÷╞ ")); } TEST(x86ild, test_4080E600) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPR8_IMMb_80r4 ISA_SET: I86 SHORT: and sil, 0x0 */ ASSERT_EQ(4, ild(u"@Çμ ")); } TEST(x86ild, test_09CA) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or edx, ecx */ ASSERT_EQ(2, ild(u"○╩")); } TEST(x86ild, test_85ED) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test ebp, ebp */ ASSERT_EQ(2, ild(u"àφ")); } TEST(x86ild, test_83E500) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and ebp, 0x0 */ ASSERT_EQ(3, ild(u"âσ ")); } TEST(x86ild, test_834A0000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_MEMv_IMMb ISA_SET: I86 SHORT: or dword ptr [rdx], 0x0 */ ASSERT_EQ(4, ild(u"âJ  ")); } TEST(x86ild, test_4183F100) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_IMMb ISA_SET: I86 SHORT: xor r9d, 0x0 */ ASSERT_EQ(4, ild(u"Aâ± ")); } TEST(x86ild, test_4183E200) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and r10d, 0x0 */ ASSERT_EQ(4, ild(u"AâΓ ")); } TEST(x86ild, test_4180E100) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPR8_IMMb_80r4 ISA_SET: I86 SHORT: and r9b, 0x0 */ ASSERT_EQ(4, ild(u"AÇß ")); } TEST(x86ild, test_4180E000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPR8_IMMb_80r4 ISA_SET: I86 SHORT: and r8b, 0x0 */ ASSERT_EQ(4, ild(u"AÇα ")); } TEST(x86ild, test_85DB) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test ebx, ebx */ ASSERT_EQ(2, ild(u"à█")); } TEST(x86ild, test_81480000000000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_MEMv_IMMz ISA_SET: I86 SHORT: or dword ptr [rax], 0x0 */ ASSERT_EQ(7, ild(u"üH     ")); } TEST(x86ild, test_80CE00) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPR8_IMMb_80r1 ISA_SET: I86 SHORT: or dh, 0x0 */ ASSERT_EQ(3, ild(u"Ç╬ ")); } TEST(x86ild, test_66F747000000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMv_IMMz_F7r0 ISA_SET: I86 SHORT: test word ptr [rdi], 0x0 */ ASSERT_EQ(6, ild(u"f≈G   ")); } TEST(x86ild, test_48F7D2) { /* ICLASS: NOT CATEGORY: LOGICAL EXTENSION: BASE IFORM: NOT_GPRv ISA_SET: I86 SHORT: not rdx */ ASSERT_EQ(3, ild(u"H≈╥")); } TEST(x86ild, test_4585F6) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test r14d, r14d */ ASSERT_EQ(3, ild(u"Eà÷")); } TEST(x86ild, test_4183E100) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and r9d, 0x0 */ ASSERT_EQ(4, ild(u"Aâß ")); } TEST(x86ild, test_4084F6) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPR8_GPR8 ISA_SET: I86 SHORT: test sil, sil */ ASSERT_EQ(3, ild(u"@ä÷")); } TEST(x86ild, test_31ED) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor ebp, ebp */ ASSERT_EQ(2, ild(u"1φ")); } TEST(x86ild, test_09F8) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or eax, edi */ ASSERT_EQ(2, ild(u"○°")); } TEST(x86ild, test_85FF) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test edi, edi */ ASSERT_EQ(2, ild(u"àλ")); } TEST(x86ild, test_83F600) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_IMMb ISA_SET: I86 SHORT: xor esi, 0x0 */ ASSERT_EQ(3, ild(u"â÷ ")); } TEST(x86ild, test_81CA00000000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_IMMz ISA_SET: I86 SHORT: or edx, 0x0 */ ASSERT_EQ(6, ild(u"ü╩    ")); } TEST(x86ild, test_81490000000000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_MEMv_IMMz ISA_SET: I86 SHORT: or dword ptr [rcx], 0x0 */ ASSERT_EQ(7, ild(u"üI     ")); } TEST(x86ild, test_4D85ED) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test r13, r13 */ ASSERT_EQ(3, ild(u"Màφ")); } TEST(x86ild, test_4D85E4) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test r12, r12 */ ASSERT_EQ(3, ild(u"MàΣ")); } TEST(x86ild, test_48F7D0) { /* ICLASS: NOT CATEGORY: LOGICAL EXTENSION: BASE IFORM: NOT_GPRv ISA_SET: I86 SHORT: not rax */ ASSERT_EQ(3, ild(u"H≈╨")); } TEST(x86ild, test_4885F6) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test rsi, rsi */ ASSERT_EQ(3, ild(u"Hà÷")); } TEST(x86ild, test_4585C0) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test r8d, r8d */ ASSERT_EQ(3, ild(u"Eà└")); } TEST(x86ild, test_4183F200) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_IMMb ISA_SET: I86 SHORT: xor r10d, 0x0 */ ASSERT_EQ(4, ild(u"Aâ≥ ")); } TEST(x86ild, test_31FF) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor edi, edi */ ASSERT_EQ(2, ild(u"1λ")); } TEST(x86ild, test_2400) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_AL_IMMb ISA_SET: I86 SHORT: and al, 0x0 */ ASSERT_EQ(2, ild(u"$ ")); } TEST(x86ild, test_F7D1) { /* ICLASS: NOT CATEGORY: LOGICAL EXTENSION: BASE IFORM: NOT_GPRv ISA_SET: I86 SHORT: not ecx */ ASSERT_EQ(2, ild(u"≈╤")); } TEST(x86ild, test_F7430000000000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMv_IMMz_F7r0 ISA_SET: I86 SHORT: test dword ptr [rbx], 0x0 */ ASSERT_EQ(7, ild(u"≈C     ")); } TEST(x86ild, test_83C900) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_IMMb ISA_SET: I86 SHORT: or ecx, 0x0 */ ASSERT_EQ(3, ild(u"â╔ ")); } TEST(x86ild, test_814E0000000000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_MEMv_IMMz ISA_SET: I86 SHORT: or dword ptr [rsi], 0x0 */ ASSERT_EQ(7, ild(u"üN     ")); } TEST(x86ild, test_80C900) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPR8_IMMb_80r1 ISA_SET: I86 SHORT: or cl, 0x0 */ ASSERT_EQ(3, ild(u"Ç╔ ")); } TEST(x86ild, test_668163000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_MEMv_IMMz ISA_SET: I86 SHORT: and word ptr [rbx], 0x0 */ ASSERT_EQ(6, ild(u"füc   ")); } TEST(x86ild, test_4883C900) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_IMMb ISA_SET: I86 SHORT: or rcx, 0x0 */ ASSERT_EQ(4, ild(u"Hâ╔ ")); } TEST(x86ild, test_4585E4) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test r12d, r12d */ ASSERT_EQ(3, ild(u"EàΣ")); } TEST(x86ild, test_4531F6) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor r14d, r14d */ ASSERT_EQ(3, ild(u"E1÷")); } TEST(x86ild, test_4531ED) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor r13d, r13d */ ASSERT_EQ(3, ild(u"E1φ")); } TEST(x86ild, test_4531E4) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor r12d, r12d */ ASSERT_EQ(3, ild(u"E1Σ")); } TEST(x86ild, test_4531D2) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor r10d, r10d */ ASSERT_EQ(3, ild(u"E1╥")); } TEST(x86ild, test_4531C9) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor r9d, r9d */ ASSERT_EQ(3, ild(u"E1╔")); } TEST(x86ild, test_4531C0) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor r8d, r8d */ ASSERT_EQ(3, ild(u"E1└")); } TEST(x86ild, test_4409D8) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or eax, r11d */ ASSERT_EQ(3, ild(u"D○╪")); } TEST(x86ild, test_4409C7) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or edi, r8d */ ASSERT_EQ(3, ild(u"D○╟")); } TEST(x86ild, test_4183E400) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and r12d, 0x0 */ ASSERT_EQ(4, ild(u"AâΣ ")); } TEST(x86ild, test_4181E600000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and r14d, 0x0 */ ASSERT_EQ(7, ild(u"Aüμ    ")); } TEST(x86ild, test_4180E200) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPR8_IMMb_80r4 ISA_SET: I86 SHORT: and r10b, 0x0 */ ASSERT_EQ(4, ild(u"AÇΓ ")); } TEST(x86ild, test_4109C0) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or r8d, eax */ ASSERT_EQ(3, ild(u"A○└")); } TEST(x86ild, test_21C2) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_GPRv_21 ISA_SET: I86 SHORT: and edx, eax */ ASSERT_EQ(2, ild(u"!┬")); } TEST(x86ild, test_09FA) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or edx, edi */ ASSERT_EQ(2, ild(u"○·")); } TEST(x86ild, test_09E8) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or eax, ebp */ ASSERT_EQ(2, ild(u"○Φ")); } TEST(x86ild, test_F7470000000000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMv_IMMz_F7r0 ISA_SET: I86 SHORT: test dword ptr [rdi], 0x0 */ ASSERT_EQ(7, ild(u"≈G     ")); } TEST(x86ild, test_F7400000000000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMv_IMMz_F7r0 ISA_SET: I86 SHORT: test dword ptr [rax], 0x0 */ ASSERT_EQ(7, ild(u"≈@     ")); } TEST(x86ild, test_F6040800) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMb_IMMb_F6r0 ISA_SET: I86 SHORT: test byte ptr [rax+rcx*1], 0x0 */ ASSERT_EQ(4, ild(u"÷♦◘ ")); } TEST(x86ild, test_85C9) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test ecx, ecx */ ASSERT_EQ(2, ild(u"à╔")); } TEST(x86ild, test_83F700) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_IMMb ISA_SET: I86 SHORT: xor edi, 0x0 */ ASSERT_EQ(3, ild(u"â≈ ")); } TEST(x86ild, test_83490000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_MEMv_IMMb ISA_SET: I86 SHORT: or dword ptr [rcx], 0x0 */ ASSERT_EQ(4, ild(u"âI  ")); } TEST(x86ild, test_81670000000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_MEMv_IMMz ISA_SET: I86 SHORT: and dword ptr [rdi], 0x0 */ ASSERT_EQ(7, ild(u"üg     ")); } TEST(x86ild, test_81630000000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_MEMv_IMMz ISA_SET: I86 SHORT: and dword ptr [rbx], 0x0 */ ASSERT_EQ(7, ild(u"üc     ")); } TEST(x86ild, test_66A90000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_OrAX_IMMz ISA_SET: I86 SHORT: test ax, 0x0 */ ASSERT_EQ(4, ild(u"f⌐  ")); } TEST(x86ild, test_6685F6) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test si, si */ ASSERT_EQ(3, ild(u"fà÷")); } TEST(x86ild, test_6685D2) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test dx, dx */ ASSERT_EQ(3, ild(u"fà╥")); } TEST(x86ild, test_6685C0) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test ax, ax */ ASSERT_EQ(3, ild(u"fà└")); } TEST(x86ild, test_6681E70000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and di, 0x0 */ ASSERT_EQ(5, ild(u"füτ  ")); } TEST(x86ild, test_66350000) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_OrAX_IMMz ISA_SET: I86 SHORT: xor ax, 0x0 */ ASSERT_EQ(4, ild(u"f5  ")); } TEST(x86ild, test_4D85D2) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test r10, r10 */ ASSERT_EQ(3, ild(u"Mà╥")); } TEST(x86ild, test_4D21E8) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_GPRv_21 ISA_SET: I86 SHORT: and r8, r13 */ ASSERT_EQ(3, ild(u"M!Φ")); } TEST(x86ild, test_4C31C0) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor rax, r8 */ ASSERT_EQ(3, ild(u"L1└")); } TEST(x86ild, test_4921C2) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_GPRv_21 ISA_SET: I86 SHORT: and r10, rax */ ASSERT_EQ(3, ild(u"I!┬")); } TEST(x86ild, test_48F7D1) { /* ICLASS: NOT CATEGORY: LOGICAL EXTENSION: BASE IFORM: NOT_GPRv ISA_SET: I86 SHORT: not rcx */ ASSERT_EQ(3, ild(u"H≈╤")); } TEST(x86ild, test_48859000000000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMv_GPRv ISA_SET: I86 SHORT: test qword ptr [rax], rdx */ ASSERT_EQ(7, ild(u"HàÉ    ")); } TEST(x86ild, test_48854200) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMv_GPRv ISA_SET: I86 SHORT: test qword ptr [rdx], rax */ ASSERT_EQ(4, ild(u"HàB ")); } TEST(x86ild, test_488514C7) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMv_GPRv ISA_SET: I86 SHORT: test qword ptr [rdi+rax*8], rdx */ ASSERT_EQ(4, ild(u"Hà¶╟")); } TEST(x86ild, test_488504D500000000) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_MEMv_GPRv ISA_SET: I86 SHORT: test qword ptr [rdx*8], rax */ ASSERT_EQ(8, ild(u"Hà♦╒    ")); } TEST(x86ild, test_4883E400) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and rsp, 0x0 */ ASSERT_EQ(4, ild(u"HâΣ ")); } TEST(x86ild, test_4883CB00) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_IMMb ISA_SET: I86 SHORT: or rbx, 0x0 */ ASSERT_EQ(4, ild(u"Hâ╦ ")); } TEST(x86ild, test_4883CA00) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_IMMb ISA_SET: I86 SHORT: or rdx, 0x0 */ ASSERT_EQ(4, ild(u"Hâ╩ ")); } TEST(x86ild, test_4831ED) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor rbp, rbp */ ASSERT_EQ(3, ild(u"H1φ")); } TEST(x86ild, test_48234B00) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_MEMv ISA_SET: I86 SHORT: and rcx, qword ptr [rbx] */ ASSERT_EQ(4, ild(u"H#K ")); } TEST(x86ild, test_482306) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_MEMv ISA_SET: I86 SHORT: and rax, qword ptr [rsi] */ ASSERT_EQ(3, ild(u"H#♠")); } TEST(x86ild, test_4821F8) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_GPRv_21 ISA_SET: I86 SHORT: and rax, rdi */ ASSERT_EQ(3, ild(u"H!°")); } TEST(x86ild, test_480B5700) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_MEMv ISA_SET: I86 SHORT: or rdx, qword ptr [rdi] */ ASSERT_EQ(4, ild(u"H♂W ")); } TEST(x86ild, test_4809D0) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or rax, rdx */ ASSERT_EQ(3, ild(u"H○╨")); } TEST(x86ild, test_4585FF) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPRv_GPRv ISA_SET: I86 SHORT: test r15d, r15d */ ASSERT_EQ(3, ild(u"Eàλ")); } TEST(x86ild, test_4584D2) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPR8_GPR8 ISA_SET: I86 SHORT: test r10b, r10b */ ASSERT_EQ(3, ild(u"Eä╥")); } TEST(x86ild, test_4531FF) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor r15d, r15d */ ASSERT_EQ(3, ild(u"E1λ")); } TEST(x86ild, test_4531DB) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor r11d, r11d */ ASSERT_EQ(3, ild(u"E1█")); } TEST(x86ild, test_4509DA) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or r10d, r11d */ ASSERT_EQ(3, ild(u"E○┌")); } TEST(x86ild, test_4509C8) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or r8d, r9d */ ASSERT_EQ(3, ild(u"E○╚")); } TEST(x86ild, test_450801) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_MEMb_GPR8 ISA_SET: I86 SHORT: or byte ptr [r9], r8b */ ASSERT_EQ(3, ild(u"E◘☺")); } TEST(x86ild, test_4431C0) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_GPRv_31 ISA_SET: I86 SHORT: xor eax, r8d */ ASSERT_EQ(3, ild(u"D1└")); } TEST(x86ild, test_4421C1) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_GPRv_21 ISA_SET: I86 SHORT: and ecx, r8d */ ASSERT_EQ(3, ild(u"D!┴")); } TEST(x86ild, test_4409C8) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or eax, r9d */ ASSERT_EQ(3, ild(u"D○╚")); } TEST(x86ild, test_4183F300) { /* ICLASS: XOR CATEGORY: LOGICAL EXTENSION: BASE IFORM: XOR_GPRv_IMMb ISA_SET: I86 SHORT: xor r11d, 0x0 */ ASSERT_EQ(4, ild(u"Aâ≤ ")); } TEST(x86ild, test_4183E700) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and r15d, 0x0 */ ASSERT_EQ(4, ild(u"Aâτ ")); } TEST(x86ild, test_4183E600) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and r14d, 0x0 */ ASSERT_EQ(4, ild(u"Aâμ ")); } TEST(x86ild, test_4183E300) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMb ISA_SET: I86 SHORT: and r11d, 0x0 */ ASSERT_EQ(4, ild(u"Aâπ ")); } TEST(x86ild, test_4181E700000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and r15d, 0x0 */ ASSERT_EQ(7, ild(u"Aüτ    ")); } TEST(x86ild, test_4181E500000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and r13d, 0x0 */ ASSERT_EQ(7, ild(u"Aüσ    ")); } TEST(x86ild, test_4181E000000000) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_IMMz ISA_SET: I86 SHORT: and r8d, 0x0 */ ASSERT_EQ(7, ild(u"Aüα    ")); } TEST(x86ild, test_4109D4) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPRv_GPRv_09 ISA_SET: I86 SHORT: or r12d, edx */ ASSERT_EQ(3, ild(u"A○╘")); } TEST(x86ild, test_4084FF) { /* ICLASS: TEST CATEGORY: LOGICAL EXTENSION: BASE IFORM: TEST_GPR8_GPR8 ISA_SET: I86 SHORT: test dil, dil */ ASSERT_EQ(3, ild(u"@äλ")); } TEST(x86ild, test_224300) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPR8_MEMb ISA_SET: I86 SHORT: and al, byte ptr [rbx] */ ASSERT_EQ(3, ild(u"“C ")); } TEST(x86ild, test_21F9) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_GPRv_21 ISA_SET: I86 SHORT: and ecx, edi */ ASSERT_EQ(2, ild(u"!∙")); } TEST(x86ild, test_21F8) { /* ICLASS: AND CATEGORY: LOGICAL EXTENSION: BASE IFORM: AND_GPRv_GPRv_21 ISA_SET: I86 SHORT: and eax, edi */ ASSERT_EQ(2, ild(u"!°")); } TEST(x86ild, test_093C8500000000) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_MEMv_GPRv ISA_SET: I86 SHORT: or dword ptr [rax*4], edi */ ASSERT_EQ(7, ild(u"○<à    ")); } TEST(x86ild, test_08D1) { /* ICLASS: OR CATEGORY: LOGICAL EXTENSION: BASE IFORM: OR_GPR8_GPR8_08 ISA_SET: I86 SHORT: or cl, dl */ ASSERT_EQ(2, ild(u"◘╤")); }
38,815
2,206
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/lib.h
#ifndef COSMOPOLITAN_TEST_LIBC_XED_LIB_H_ #define COSMOPOLITAN_TEST_LIBC_XED_LIB_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ int ild(const char16_t *codez); int ildreal(const char16_t *codez); int ildlegacy(const char16_t *codez); uint8_t *unbingx86op(const char16_t *codez) dontdiscard; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_TEST_LIBC_XED_LIB_H_ */
423
14
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_popular_i86_2_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" TEST(x86ild, test_4489E7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edi, r12d */ EXPECT_EQ(3, ild(u"Dëτ")); } TEST(x86ild, test_4489E0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, r12d */ EXPECT_EQ(3, ild(u"Dëα")); } TEST(x86ild, test_4489D9) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ecx, r11d */ EXPECT_EQ(3, ild(u"Dë┘")); } TEST(x86ild, test_4488D0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov al, r10b */ EXPECT_EQ(3, ild(u"Dê╨")); } TEST(x86ild, test_41BE00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov r14d, 0x0 */ EXPECT_EQ(6, ild(u"A╛    ")); } TEST(x86ild, test_41B900000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov r9d, 0x0 */ EXPECT_EQ(6, ild(u"A╣    ")); } TEST(x86ild, test_4189E8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r8d, ebp */ EXPECT_EQ(3, ild(u"AëΦ")); } TEST(x86ild, test_4189D0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r8d, edx */ EXPECT_EQ(3, ild(u"Aë╨")); } TEST(x86ild, test_4189C7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r15d, eax */ EXPECT_EQ(3, ild(u"Aë╟")); } TEST(x86ild, test_4188C0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r8b, al */ EXPECT_EQ(3, ild(u"Aê└")); } TEST(x86ild, test_408A7B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dil, byte ptr [rbx] */ EXPECT_EQ(4, ild(u"@è{ ")); } TEST(x86ild, test_4088F1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov cl, sil */ EXPECT_EQ(3, ild(u"@ê±")); } TEST(x86ild, test_4088D6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov sil, dl */ EXPECT_EQ(3, ild(u"@ê╓")); } TEST(x86ild, test_4088C7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dil, al */ EXPECT_EQ(3, ild(u"@ê╟")); } TEST(x86ild, test_0F8300000000) { /* ICLASS: JNB CATEGORY: COND_BR EXTENSION: BASE IFORM: JNB_RELBRd ISA_SET: I86 SHORT: jnb 0x6 */ EXPECT_EQ(6, ild(u"☼â    ")); } TEST(x86ild, test_FF24F500000000) { /* ICLASS: JMP CATEGORY: UNCOND_BR EXTENSION: BASE IFORM: JMP_MEMv ISA_SET: I86 SHORT: jmp qword ptr [rsi*8] */ EXPECT_EQ(7, ild(u"λ$⌡    ")); } TEST(x86ild, test_E80083E200) { /* ICLASS: CALL_NEAR CATEGORY: CALL EXTENSION: BASE IFORM: CALL_NEAR_RELBRd ISA_SET: I86 SHORT: call 0xe28305 */ EXPECT_EQ(5, ild(u"Φ âΓ ")); } TEST(x86ild, test_D3E7) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_CL_D3r4 ISA_SET: I86 SHORT: shl edi, cl */ EXPECT_EQ(2, ild(u"╙τ")); } TEST(x86ild, test_D2C1) { /* ICLASS: ROL CATEGORY: ROTATE EXTENSION: BASE IFORM: ROL_GPR8_CL ISA_SET: I86 SHORT: rol cl, cl */ EXPECT_EQ(2, ild(u"╥┴")); } TEST(x86ild, test_C784240000000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov dword ptr [rsp], 0x0 */ EXPECT_EQ(11, ild(u"╟ä$        ")); } TEST(x86ild, test_C744240000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov dword ptr [rsp], 0x0 */ EXPECT_EQ(8, ild(u"╟D$     ")); } TEST(x86ild, test_C6840E0000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rsi+rcx*1], 0x0 */ EXPECT_EQ(8, ild(u"╞ä♫     ")); } TEST(x86ild, test_C6420000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rdx], 0x0 */ EXPECT_EQ(4, ild(u"╞B  ")); } TEST(x86ild, test_C60700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rdi], 0x0 */ EXPECT_EQ(3, ild(u"╞• ")); } TEST(x86ild, test_C60600) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rsi], 0x0 */ EXPECT_EQ(3, ild(u"╞♠ ")); } TEST(x86ild, test_8BB200000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov esi, dword ptr [rdx] */ EXPECT_EQ(6, ild(u"ï▓    ")); } TEST(x86ild, test_8B7F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edi, dword ptr [rdi] */ EXPECT_EQ(3, ild(u"ï⌂ ")); } TEST(x86ild, test_8B7C2400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edi, dword ptr [rsp] */ EXPECT_EQ(4, ild(u"ï|$ ")); } TEST(x86ild, test_8B7B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edi, dword ptr [rbx] */ EXPECT_EQ(3, ild(u"ï{ ")); } TEST(x86ild, test_8B5100) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rcx] */ EXPECT_EQ(3, ild(u"ïQ ")); } TEST(x86ild, test_8B4C2400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rsp] */ EXPECT_EQ(4, ild(u"ïL$ ")); } TEST(x86ild, test_8B16) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rsi] */ EXPECT_EQ(2, ild(u"ï▬")); } TEST(x86ild, test_8B10) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rax] */ EXPECT_EQ(2, ild(u"ï►")); } TEST(x86ild, test_8B0C8500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rax*4] */ EXPECT_EQ(7, ild(u"ï♀à    ")); } TEST(x86ild, test_8B04FD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rdi*8] */ EXPECT_EQ(7, ild(u"ï♦²    ")); } TEST(x86ild, test_8B04C500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rax*8] */ EXPECT_EQ(7, ild(u"ï♦┼    ")); } TEST(x86ild, test_8B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rax] */ EXPECT_EQ(2, ild(u"ï ")); } TEST(x86ild, test_8A14C500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rax*8] */ EXPECT_EQ(7, ild(u"è¶┼    ")); } TEST(x86ild, test_8A0401) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rcx+rax*1] */ EXPECT_EQ(3, ild(u"è♦☺")); } TEST(x86ild, test_89FB) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ebx, edi */ EXPECT_EQ(2, ild(u"ë√")); } TEST(x86ild, test_89DF) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edi, ebx */ EXPECT_EQ(2, ild(u"ë▀")); } TEST(x86ild, test_89D8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, ebx */ EXPECT_EQ(2, ild(u"ë╪")); } TEST(x86ild, test_89CB) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ebx, ecx */ EXPECT_EQ(2, ild(u"ë╦")); } TEST(x86ild, test_899A00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdx], ebx */ EXPECT_EQ(6, ild(u"ëÜ    ")); } TEST(x86ild, test_894B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rbx], ecx */ EXPECT_EQ(3, ild(u"ëK ")); } TEST(x86ild, test_890424) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rsp], eax */ EXPECT_EQ(3, ild(u"ë♦$")); } TEST(x86ild, test_8810) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rax], dl */ EXPECT_EQ(2, ild(u"ê►")); } TEST(x86ild, test_66C747000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov word ptr [rdi], 0x0 */ EXPECT_EQ(6, ild(u"f╟G   ")); } TEST(x86ild, test_668910) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rax], dx */ EXPECT_EQ(3, ild(u"fë►")); } TEST(x86ild, test_4D89EC) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r12, r13 */ EXPECT_EQ(3, ild(u"Më∞")); } TEST(x86ild, test_4C89FA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdx, r15 */ EXPECT_EQ(3, ild(u"Lë·")); } TEST(x86ild, test_4C89E6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, r12 */ EXPECT_EQ(3, ild(u"Lëμ")); } TEST(x86ild, test_4C89D0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rax, r10 */ EXPECT_EQ(3, ild(u"Lë╨")); } TEST(x86ild, test_49D3E0) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_CL_D3r4 ISA_SET: I86 SHORT: shl r8, cl */ EXPECT_EQ(3, ild(u"I╙α")); } TEST(x86ild, test_4989F4) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r12, rsi */ EXPECT_EQ(3, ild(u"Ië⌠")); } TEST(x86ild, test_4989C4) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r12, rax */ EXPECT_EQ(3, ild(u"Ië─")); } TEST(x86ild, test_48BF0000000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov rdi, 0x0 */ EXPECT_EQ(10, ild(u"H┐        ")); } TEST(x86ild, test_488B9100000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rcx] */ EXPECT_EQ(7, ild(u"Hïæ    ")); } TEST(x86ild, test_488B7700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rsi, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"Hïw ")); } TEST(x86ild, test_488B5200) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rdx] */ EXPECT_EQ(4, ild(u"HïR ")); } TEST(x86ild, test_488B04D0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rax+rdx*8] */ EXPECT_EQ(4, ild(u"Hï♦╨")); } TEST(x86ild, test_4889E9) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rcx, rbp */ EXPECT_EQ(3, ild(u"HëΘ")); } TEST(x86ild, test_4889E7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdi, rsp */ EXPECT_EQ(3, ild(u"Hëτ")); } TEST(x86ild, test_4889D7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdi, rdx */ EXPECT_EQ(3, ild(u"Hë╫")); } TEST(x86ild, test_4889CD) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbp, rcx */ EXPECT_EQ(3, ild(u"Hë═")); } TEST(x86ild, test_48895700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rdi], rdx */ EXPECT_EQ(4, ild(u"HëW ")); } TEST(x86ild, test_48894700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rdi], rax */ EXPECT_EQ(4, ild(u"HëG ")); } TEST(x86ild, test_48894300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rbx], rax */ EXPECT_EQ(4, ild(u"HëC ")); } TEST(x86ild, test_488910) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rax], rdx */ EXPECT_EQ(3, ild(u"Hë►")); } TEST(x86ild, test_48890D00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rip], rcx */ EXPECT_EQ(7, ild(u"Hë♪    ")); } TEST(x86ild, test_488902) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rdx], rax */ EXPECT_EQ(3, ild(u"Hë☻")); } TEST(x86ild, test_4863D2) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd rdx, edx */ EXPECT_EQ(3, ild(u"Hc╥")); } TEST(x86ild, test_4589CA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r10d, r9d */ EXPECT_EQ(3, ild(u"Eë╩")); } TEST(x86ild, test_4588C8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r8b, r9b */ EXPECT_EQ(3, ild(u"Eê╚")); } TEST(x86ild, test_4489FA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edx, r15d */ EXPECT_EQ(3, ild(u"Dë·")); } TEST(x86ild, test_4489F7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edi, r14d */ EXPECT_EQ(3, ild(u"Dë≈")); } TEST(x86ild, test_4489EF) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edi, r13d */ EXPECT_EQ(3, ild(u"Dë∩")); } TEST(x86ild, test_4489E1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ecx, r12d */ EXPECT_EQ(3, ild(u"Dëß")); } TEST(x86ild, test_4489442400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rsp], r8d */ EXPECT_EQ(5, ild(u"DëD$ ")); } TEST(x86ild, test_4488CA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dl, r9b */ EXPECT_EQ(3, ild(u"Dê╩")); } TEST(x86ild, test_44885300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], r10b */ EXPECT_EQ(4, ild(u"DêS ")); } TEST(x86ild, test_44884300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], r8b */ EXPECT_EQ(4, ild(u"DêC ")); } TEST(x86ild, test_428B148D00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [r9*4] */ EXPECT_EQ(8, ild(u"Bï¶ì    ")); } TEST(x86ild, test_41D3E0) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_CL_D3r4 ISA_SET: I86 SHORT: shl r8d, cl */ EXPECT_EQ(3, ild(u"A╙α")); } TEST(x86ild, test_41BF00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov r15d, 0x0 */ EXPECT_EQ(6, ild(u"A┐    ")); } TEST(x86ild, test_41BD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov r13d, 0x0 */ EXPECT_EQ(6, ild(u"A╜    ")); } TEST(x86ild, test_41B800000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMv ISA_SET: I86 SHORT: mov r8d, 0x0 */ EXPECT_EQ(6, ild(u"A╕    ")); } TEST(x86ild, test_4189F4) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r12d, esi */ EXPECT_EQ(3, ild(u"Aë⌠")); } TEST(x86ild, test_4189F2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r10d, esi */ EXPECT_EQ(3, ild(u"Aë≥")); } TEST(x86ild, test_4189C8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r8d, ecx */ EXPECT_EQ(3, ild(u"Aë╚")); } TEST(x86ild, test_4088F9) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov cl, dil */ EXPECT_EQ(3, ild(u"@ê∙")); } TEST(x86ild, test_4088F2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dl, sil */ EXPECT_EQ(3, ild(u"@ê≥")); } TEST(x86ild, test_4088E8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov al, bpl */ EXPECT_EQ(3, ild(u"@êΦ")); } TEST(x86ild, test_0F8900000000) { /* ICLASS: JNS CATEGORY: COND_BR EXTENSION: BASE IFORM: JNS_RELBRd ISA_SET: I86 SHORT: jns 0x6 */ EXPECT_EQ(6, ild(u"☼ë    ")); } TEST(x86ild, test_0F8600000000) { /* ICLASS: JBE CATEGORY: COND_BR EXTENSION: BASE IFORM: JBE_RELBRd ISA_SET: I86 SHORT: jbe 0x6 */ EXPECT_EQ(6, ild(u"☼å    ")); } TEST(x86ild, test_FF14C500000000) { /* ICLASS: CALL_NEAR CATEGORY: CALL EXTENSION: BASE IFORM: CALL_NEAR_MEMv ISA_SET: I86 SHORT: call qword ptr [rax*8] */ EXPECT_EQ(7, ild(u"λ¶┼    ")); } TEST(x86ild, test_F3C3) { /* ICLASS: RET_NEAR CATEGORY: RET EXTENSION: BASE IFORM: RET_NEAR ISA_SET: I86 SHORT: ret */ EXPECT_EQ(2, ild(u"≤├")); } TEST(x86ild, test_F3A4) { /* ICLASS: REP_MOVSB CATEGORY: STRINGOP EXTENSION: BASE IFORM: REP_MOVSB ISA_SET: I86 SHORT: rep movsb byte ptr [rdi], byte ptr [rsi] */ EXPECT_EQ(2, ild(u"≤ñ")); } TEST(x86ild, test_D3E2) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_CL_D3r4 ISA_SET: I86 SHORT: shl edx, cl */ EXPECT_EQ(2, ild(u"╙Γ")); } TEST(x86ild, test_C6040300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rbx+rax*1], 0x0 */ EXPECT_EQ(4, ild(u"╞♦♥ ")); } TEST(x86ild, test_C60100) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [rcx], 0x0 */ EXPECT_EQ(3, ild(u"╞☺ ")); } TEST(x86ild, test_B200) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_IMMb_B0 ISA_SET: I86 SHORT: mov dl, 0x0 */ EXPECT_EQ(2, ild(u"▓ ")); } TEST(x86ild, test_8B8100000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rcx] */ EXPECT_EQ(6, ild(u"ïü    ")); } TEST(x86ild, test_8B7500) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov esi, dword ptr [rbp] */ EXPECT_EQ(3, ild(u"ïu ")); } TEST(x86ild, test_8B6800) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ebp, dword ptr [rax] */ EXPECT_EQ(3, ild(u"ïh ")); } TEST(x86ild, test_8B4800) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rax] */ EXPECT_EQ(3, ild(u"ïH ")); } TEST(x86ild, test_8B4500) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rbp] */ EXPECT_EQ(3, ild(u"ïE ")); } TEST(x86ild, test_8B3F) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edi, dword ptr [rdi] */ EXPECT_EQ(2, ild(u"ï?")); } TEST(x86ild, test_8B3C24) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edi, dword ptr [rsp] */ EXPECT_EQ(3, ild(u"ï<$")); } TEST(x86ild, test_8B348500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov esi, dword ptr [rax*4] */ EXPECT_EQ(7, ild(u"ï4à    ")); } TEST(x86ild, test_8B28) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ebp, dword ptr [rax] */ EXPECT_EQ(2, ild(u"ï(")); } TEST(x86ild, test_8B1E) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ebx, dword ptr [rsi] */ EXPECT_EQ(2, ild(u"ï▲")); } TEST(x86ild, test_8B1500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rip] */ EXPECT_EQ(6, ild(u"易   ")); } TEST(x86ild, test_8B14F500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rsi*8] */ EXPECT_EQ(7, ild(u"ï¶⌡    ")); } TEST(x86ild, test_8B14C500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov edx, dword ptr [rax*8] */ EXPECT_EQ(7, ild(u"ï¶┼    ")); } TEST(x86ild, test_8B0CCD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rcx*8] */ EXPECT_EQ(7, ild(u"ï♀═    ")); } TEST(x86ild, test_8B0CBD00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rdi*4] */ EXPECT_EQ(7, ild(u"ï♀╜    ")); } TEST(x86ild, test_8B0CB500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rsi*4] */ EXPECT_EQ(7, ild(u"ï♀╡    ")); } TEST(x86ild, test_8B0C8D00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov ecx, dword ptr [rcx*4] */ EXPECT_EQ(7, ild(u"ï♀ì    ")); } TEST(x86ild, test_8B06) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rsi] */ EXPECT_EQ(2, ild(u"ï♠")); } TEST(x86ild, test_8B04B500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [rsi*4] */ EXPECT_EQ(7, ild(u"ï♦╡    ")); } TEST(x86ild, test_8A9200000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rdx] */ EXPECT_EQ(6, ild(u"èÆ    ")); } TEST(x86ild, test_8A8900000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rcx] */ EXPECT_EQ(6, ild(u"èë    ")); } TEST(x86ild, test_8A841000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rax+rdx*1] */ EXPECT_EQ(7, ild(u"èä►    ")); } TEST(x86ild, test_8A542400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rsp] */ EXPECT_EQ(4, ild(u"èT$ ")); } TEST(x86ild, test_8A4E00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rsi] */ EXPECT_EQ(3, ild(u"èN ")); } TEST(x86ild, test_8A4D00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rbp] */ EXPECT_EQ(3, ild(u"èM ")); } TEST(x86ild, test_8A14F500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rsi*8] */ EXPECT_EQ(7, ild(u"è¶⌡    ")); } TEST(x86ild, test_8A149500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rdx*4] */ EXPECT_EQ(7, ild(u"è¶ò    ")); } TEST(x86ild, test_8A1411) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rcx+rdx*1] */ EXPECT_EQ(3, ild(u"è¶◄")); } TEST(x86ild, test_8A140A) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rdx+rcx*1] */ EXPECT_EQ(3, ild(u"è¶◙")); } TEST(x86ild, test_8A1402) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rdx+rax*1] */ EXPECT_EQ(3, ild(u"è¶☻")); } TEST(x86ild, test_8A0C01) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [rcx+rax*1] */ EXPECT_EQ(3, ild(u"è♀☺")); } TEST(x86ild, test_8A06) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rsi] */ EXPECT_EQ(2, ild(u"è♠")); } TEST(x86ild, test_8A0406) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rsi+rax*1] */ EXPECT_EQ(3, ild(u"è♦♠")); } TEST(x86ild, test_8A0402) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rdx+rax*1] */ EXPECT_EQ(3, ild(u"è♦☻")); } TEST(x86ild, test_89F9) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ecx, edi */ EXPECT_EQ(2, ild(u"ë∙")); } TEST(x86ild, test_89F3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ebx, esi */ EXPECT_EQ(2, ild(u"ë≤")); } TEST(x86ild, test_89E9) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ecx, ebp */ EXPECT_EQ(2, ild(u"ëΘ")); } TEST(x86ild, test_89D7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edi, edx */ EXPECT_EQ(2, ild(u"ë╫")); } TEST(x86ild, test_89D3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ebx, edx */ EXPECT_EQ(2, ild(u"ë╙")); } TEST(x86ild, test_89AA00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdx], ebp */ EXPECT_EQ(6, ild(u"묠   ")); } TEST(x86ild, test_89942400000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rsp], edx */ EXPECT_EQ(7, ild(u"ëö$    ")); } TEST(x86ild, test_898200000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rdx], eax */ EXPECT_EQ(6, ild(u"ëé    ")); } TEST(x86ild, test_897C2400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rsp], edi */ EXPECT_EQ(4, ild(u"ë|$ ")); } TEST(x86ild, test_895D00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rbp], ebx */ EXPECT_EQ(3, ild(u"ë] ")); } TEST(x86ild, test_895800) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rax], ebx */ EXPECT_EQ(3, ild(u"ëX ")); } TEST(x86ild, test_894C2400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rsp], ecx */ EXPECT_EQ(4, ild(u"ëL$ ")); } TEST(x86ild, test_894500) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rbp], eax */ EXPECT_EQ(3, ild(u"ëE ")); } TEST(x86ild, test_893D00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rip], edi */ EXPECT_EQ(6, ild(u"ë=    ")); } TEST(x86ild, test_891500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rip], edx */ EXPECT_EQ(6, ild(u"맠   ")); } TEST(x86ild, test_8903) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rbx], eax */ EXPECT_EQ(2, ild(u"ë♥")); } TEST(x86ild, test_88540700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rdi+rax*1], dl */ EXPECT_EQ(4, ild(u"êT• ")); } TEST(x86ild, test_88540300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx+rax*1], dl */ EXPECT_EQ(4, ild(u"êT♥ ")); } TEST(x86ild, test_885100) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rcx], dl */ EXPECT_EQ(3, ild(u"êQ ")); } TEST(x86ild, test_88442400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rsp], al */ EXPECT_EQ(4, ild(u"êD$ ")); } TEST(x86ild, test_88441400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rsp+rdx*1], al */ EXPECT_EQ(4, ild(u"êD¶ ")); } TEST(x86ild, test_880C33) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx+rsi*1], cl */ EXPECT_EQ(3, ild(u"ê♀3")); } TEST(x86ild, test_66C782000000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov word ptr [rdx], 0x0 */ EXPECT_EQ(9, ild(u"f╟é      ")); } TEST(x86ild, test_6690) { /* ICLASS: NOP CATEGORY: NOP EXTENSION: BASE IFORM: NOP_90 ISA_SET: I86 SHORT: data16 nop */ EXPECT_EQ(2, ild(u"fÉ")); } TEST(x86ild, test_668B940000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov dx, word ptr [rax+rax*1] */ EXPECT_EQ(8, ild(u"fïö     ")); } TEST(x86ild, test_668B4B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov cx, word ptr [rbx] */ EXPECT_EQ(4, ild(u"fïK ")); } TEST(x86ild, test_66897B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rbx], di */ EXPECT_EQ(4, ild(u"fë{ ")); } TEST(x86ild, test_66894B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rbx], cx */ EXPECT_EQ(4, ild(u"fëK ")); } TEST(x86ild, test_668902) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov word ptr [rdx], ax */ EXPECT_EQ(3, ild(u"fë☻")); } TEST(x86ild, test_66448B7500) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r14w, word ptr [rbp] */ EXPECT_EQ(5, ild(u"fDïu ")); } TEST(x86ild, test_66448B6F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r13w, word ptr [rdi] */ EXPECT_EQ(5, ild(u"fDïo ")); } TEST(x86ild, test_66448B4700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r8w, word ptr [rdi] */ EXPECT_EQ(5, ild(u"fDïG ")); } TEST(x86ild, test_4D89C3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r11, r8 */ EXPECT_EQ(3, ild(u"Më├")); } TEST(x86ild, test_4D63EE) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd r13, r14d */ EXPECT_EQ(3, ild(u"Mcε")); } TEST(x86ild, test_4D63C0) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd r8, r8d */ EXPECT_EQ(3, ild(u"Mc└")); } TEST(x86ild, test_4C8B7700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r14, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"Lïw ")); } TEST(x86ild, test_4C8B6F00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r13, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"Lïo ")); } TEST(x86ild, test_4C8B6D00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r13, qword ptr [rbp] */ EXPECT_EQ(4, ild(u"Lïm ")); } TEST(x86ild, test_4C8B6700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r12, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"Lïg ")); } TEST(x86ild, test_4C8B6300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r12, qword ptr [rbx] */ EXPECT_EQ(4, ild(u"Lïc ")); } TEST(x86ild, test_4C8B4700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r8, qword ptr [rdi] */ EXPECT_EQ(4, ild(u"LïG ")); } TEST(x86ild, test_4C8B4300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r8, qword ptr [rbx] */ EXPECT_EQ(4, ild(u"LïC ")); } TEST(x86ild, test_4C8B2500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r12, qword ptr [rip] */ EXPECT_EQ(7, ild(u"Lï%    ")); } TEST(x86ild, test_4C89EE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, r13 */ EXPECT_EQ(3, ild(u"Lëε")); } TEST(x86ild, test_4C89EA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdx, r13 */ EXPECT_EQ(3, ild(u"LëΩ")); } TEST(x86ild, test_4C89CE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, r9 */ EXPECT_EQ(3, ild(u"Lë╬")); } TEST(x86ild, test_4C89C6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, r8 */ EXPECT_EQ(3, ild(u"Lë╞")); } TEST(x86ild, test_4C897300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rbx], r14 */ EXPECT_EQ(4, ild(u"Lës ")); } TEST(x86ild, test_4C896300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rbx], r12 */ EXPECT_EQ(4, ild(u"Lëc ")); } TEST(x86ild, test_4A8B34C500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rsi, qword ptr [r8*8] */ EXPECT_EQ(8, ild(u"Jï4┼    ")); } TEST(x86ild, test_49D3ED) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_CL ISA_SET: I86 SHORT: shr r13, cl */ EXPECT_EQ(3, ild(u"I╙φ")); } TEST(x86ild, test_4989FD) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r13, rdi */ EXPECT_EQ(3, ild(u"Ië²")); } TEST(x86ild, test_4989F6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r14, rsi */ EXPECT_EQ(3, ild(u"Ië÷")); } TEST(x86ild, test_4989F5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r13, rsi */ EXPECT_EQ(3, ild(u"Ië⌡")); } TEST(x86ild, test_4989F2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r10, rsi */ EXPECT_EQ(3, ild(u"Ië≥")); } TEST(x86ild, test_4989E4) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r12, rsp */ EXPECT_EQ(3, ild(u"IëΣ")); } TEST(x86ild, test_4989D0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r8, rdx */ EXPECT_EQ(3, ild(u"Ië╨")); } TEST(x86ild, test_4989CD) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r13, rcx */ EXPECT_EQ(3, ild(u"Ië═")); } TEST(x86ild, test_4989C5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r13, rax */ EXPECT_EQ(3, ild(u"Ië┼")); } TEST(x86ild, test_4963F7) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd rsi, r15d */ EXPECT_EQ(3, ild(u"Ic≈")); } TEST(x86ild, test_48D3C0) { /* ICLASS: ROL CATEGORY: ROTATE EXTENSION: BASE IFORM: ROL_GPRv_CL ISA_SET: I86 SHORT: rol rax, cl */ EXPECT_EQ(3, ild(u"H╙└")); } TEST(x86ild, test_48C7C000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_IMMz ISA_SET: I86 SHORT: mov rax, 0x0 */ EXPECT_EQ(7, ild(u"H╟└    ")); } TEST(x86ild, test_48C70300000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_IMMz ISA_SET: I86 SHORT: mov qword ptr [rbx], 0x0 */ EXPECT_EQ(7, ild(u"H╟♥    ")); } TEST(x86ild, test_488B9000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rax] */ EXPECT_EQ(7, ild(u"HïÉ    ")); } TEST(x86ild, test_488B8600000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rsi] */ EXPECT_EQ(7, ild(u"Hïå    ")); } TEST(x86ild, test_488B7B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdi, qword ptr [rbx] */ EXPECT_EQ(4, ild(u"Hï{ ")); } TEST(x86ild, test_488B7300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rsi, qword ptr [rbx] */ EXPECT_EQ(4, ild(u"Hïs ")); } TEST(x86ild, test_488B4500) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rbp] */ EXPECT_EQ(4, ild(u"HïE ")); } TEST(x86ild, test_488B4100) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rcx] */ EXPECT_EQ(4, ild(u"HïA ")); } TEST(x86ild, test_488B37) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rsi, qword ptr [rdi] */ EXPECT_EQ(3, ild(u"Hï7")); } TEST(x86ild, test_488B3424) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rsi, qword ptr [rsp] */ EXPECT_EQ(4, ild(u"Hï4$")); } TEST(x86ild, test_488B33) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rsi, qword ptr [rbx] */ EXPECT_EQ(3, ild(u"Hï3")); } TEST(x86ild, test_488B1D00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rbx, qword ptr [rip] */ EXPECT_EQ(7, ild(u"Hï↔    ")); } TEST(x86ild, test_488B14CA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rdx+rcx*8] */ EXPECT_EQ(4, ild(u"Hï¶╩")); } TEST(x86ild, test_488B13) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rbx] */ EXPECT_EQ(3, ild(u"Hï‼")); } TEST(x86ild, test_488B12) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rdx, qword ptr [rdx] */ EXPECT_EQ(3, ild(u"Hï↕")); } TEST(x86ild, test_488B0D00000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rcx, qword ptr [rip] */ EXPECT_EQ(7, ild(u"Hï♪    ")); } TEST(x86ild, test_488B07) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rdi] */ EXPECT_EQ(3, ild(u"Hï•")); } TEST(x86ild, test_488B04F500000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rsi*8] */ EXPECT_EQ(8, ild(u"Hï♦⌡    ")); } TEST(x86ild, test_488B03) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rbx] */ EXPECT_EQ(3, ild(u"Hï♥")); } TEST(x86ild, test_488B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov rax, qword ptr [rax] */ EXPECT_EQ(3, ild(u"Hï ")); } TEST(x86ild, test_4889FA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdx, rdi */ EXPECT_EQ(3, ild(u"Hë·")); } TEST(x86ild, test_4889F8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rax, rdi */ EXPECT_EQ(3, ild(u"Hë°")); } TEST(x86ild, test_4889F1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rcx, rsi */ EXPECT_EQ(3, ild(u"Hë±")); } TEST(x86ild, test_4889D6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rsi, rdx */ EXPECT_EQ(3, ild(u"Hë╓")); } TEST(x86ild, test_4889D3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbx, rdx */ EXPECT_EQ(3, ild(u"Hë╙")); } TEST(x86ild, test_4889CA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rdx, rcx */ EXPECT_EQ(3, ild(u"Hë╩")); } TEST(x86ild, test_4889C5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov rbp, rax */ EXPECT_EQ(3, ild(u"Hë┼")); } TEST(x86ild, test_48895300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rbx], rdx */ EXPECT_EQ(4, ild(u"HëS ")); } TEST(x86ild, test_48893424) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rsp], rsi */ EXPECT_EQ(4, ild(u"Hë4$")); } TEST(x86ild, test_488917) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rdi], rdx */ EXPECT_EQ(3, ild(u"Hë↨")); } TEST(x86ild, test_488913) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rbx], rdx */ EXPECT_EQ(3, ild(u"Hë‼")); } TEST(x86ild, test_488907) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rdi], rax */ EXPECT_EQ(3, ild(u"Hë•")); } TEST(x86ild, test_488906) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov qword ptr [rsi], rax */ EXPECT_EQ(3, ild(u"Hë♠")); } TEST(x86ild, test_4863F8) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd rdi, eax */ EXPECT_EQ(3, ild(u"Hc°")); } TEST(x86ild, test_4863D0) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd rdx, eax */ EXPECT_EQ(3, ild(u"Hc╨")); } TEST(x86ild, test_4863C8) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd rcx, eax */ EXPECT_EQ(3, ild(u"Hc╚")); } TEST(x86ild, test_4863C7) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_GPR32 ISA_SET: LONGMODE SHORT: movsxd rax, edi */ EXPECT_EQ(3, ild(u"Hc╟")); } TEST(x86ild, test_486312) { /* ICLASS: MOVSXD CATEGORY: DATAXFER EXTENSION: LONGMODE IFORM: MOVSXD_GPRv_MEMd ISA_SET: LONGMODE SHORT: movsxd rdx, dword ptr [rdx] */ EXPECT_EQ(3, ild(u"Hc↕")); } TEST(x86ild, test_47882C0E) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [r14+r9*1], r13b */ EXPECT_EQ(4, ild(u"Gê,♫")); } TEST(x86ild, test_458B9000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r10d, dword ptr [r8] */ EXPECT_EQ(7, ild(u"EïÉ    ")); } TEST(x86ild, test_4589D8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r8d, r11d */ EXPECT_EQ(3, ild(u"Eë╪")); } TEST(x86ild, test_4589CB) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r11d, r9d */ EXPECT_EQ(3, ild(u"Eë╦")); } TEST(x86ild, test_4589C1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r9d, r8d */ EXPECT_EQ(3, ild(u"Eë┴")); } TEST(x86ild, test_4588F8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r8b, r15b */ EXPECT_EQ(3, ild(u"Eê°")); } TEST(x86ild, test_4588D3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r11b, r10b */ EXPECT_EQ(3, ild(u"Eê╙")); } TEST(x86ild, test_4588D1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r9b, r10b */ EXPECT_EQ(3, ild(u"Eê╤")); } TEST(x86ild, test_4588C7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r15b, r8b */ EXPECT_EQ(3, ild(u"Eê╟")); } TEST(x86ild, test_45883424) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [r12], r14b */ EXPECT_EQ(4, ild(u"Eê4$")); } TEST(x86ild, test_448B8100000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r8d, dword ptr [rcx] */ EXPECT_EQ(7, ild(u"Dïü    ")); } TEST(x86ild, test_448B7D00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r15d, dword ptr [rbp] */ EXPECT_EQ(4, ild(u"Dï} ")); } TEST(x86ild, test_448B7700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r14d, dword ptr [rdi] */ EXPECT_EQ(4, ild(u"Dïw ")); } TEST(x86ild, test_448B6700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r12d, dword ptr [rdi] */ EXPECT_EQ(4, ild(u"Dïg ")); } TEST(x86ild, test_448B4700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r8d, dword ptr [rdi] */ EXPECT_EQ(4, ild(u"DïG ")); } TEST(x86ild, test_448B4500) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r8d, dword ptr [rbp] */ EXPECT_EQ(4, ild(u"DïE ")); } TEST(x86ild, test_448B0424) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov r8d, dword ptr [rsp] */ EXPECT_EQ(4, ild(u"Dï♦$")); } TEST(x86ild, test_448A5300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov r10b, byte ptr [rbx] */ EXPECT_EQ(4, ild(u"DèS ")); } TEST(x86ild, test_448A4E00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov r9b, byte ptr [rsi] */ EXPECT_EQ(4, ild(u"DèN ")); } TEST(x86ild, test_448A4600) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov r8b, byte ptr [rsi] */ EXPECT_EQ(4, ild(u"DèF ")); } TEST(x86ild, test_448A01) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov r8b, byte ptr [rcx] */ EXPECT_EQ(3, ild(u"Dè☺")); } TEST(x86ild, test_4489E9) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov ecx, r13d */ EXPECT_EQ(3, ild(u"DëΘ")); } TEST(x86ild, test_4489E8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, r13d */ EXPECT_EQ(3, ild(u"DëΦ")); } TEST(x86ild, test_4489CE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov esi, r9d */ EXPECT_EQ(3, ild(u"Dë╬")); } TEST(x86ild, test_4489C8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, r9d */ EXPECT_EQ(3, ild(u"Dë╚")); } TEST(x86ild, test_4489C2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov edx, r8d */ EXPECT_EQ(3, ild(u"Dë┬")); } TEST(x86ild, test_4489C0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov eax, r8d */ EXPECT_EQ(3, ild(u"Dë└")); } TEST(x86ild, test_44898900000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [rcx], r9d */ EXPECT_EQ(7, ild(u"Dëë    ")); } TEST(x86ild, test_4488E8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov al, r13b */ EXPECT_EQ(3, ild(u"DêΦ")); } TEST(x86ild, test_4488D9) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov cl, r11b */ EXPECT_EQ(3, ild(u"Dê┘")); } TEST(x86ild, test_4488CE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov sil, r9b */ EXPECT_EQ(3, ild(u"Dê╬")); } TEST(x86ild, test_4488CD) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov bpl, r9b */ EXPECT_EQ(3, ild(u"Dê═")); } TEST(x86ild, test_4488C5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov bpl, r8b */ EXPECT_EQ(3, ild(u"Dê┼")); } TEST(x86ild, test_44886300) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], r12b */ EXPECT_EQ(4, ild(u"Dêc ")); } TEST(x86ild, test_44884B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], r9b */ EXPECT_EQ(4, ild(u"DêK ")); } TEST(x86ild, test_44884700) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rdi], r8b */ EXPECT_EQ(4, ild(u"DêG ")); } TEST(x86ild, test_44884000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rax], r8b */ EXPECT_EQ(4, ild(u"Dê@ ")); } TEST(x86ild, test_43C6040E00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [r14+r9*1], 0x0 */ EXPECT_EQ(5, ild(u"C╞♦♫ ")); } TEST(x86ild, test_428A1400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dl, byte ptr [rax+r8*1] */ EXPECT_EQ(4, ild(u"B趠")); } TEST(x86ild, test_428A0406) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [rsi+r8*1] */ EXPECT_EQ(4, ild(u"Bè♦♠")); } TEST(x86ild, test_42880407) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rdi+r8*1], al */ EXPECT_EQ(4, ild(u"Bê♦•")); } TEST(x86ild, test_41FF14C4) { /* ICLASS: CALL_NEAR CATEGORY: CALL EXTENSION: BASE IFORM: CALL_NEAR_MEMv ISA_SET: I86 SHORT: call qword ptr [r12+rax*8] */ EXPECT_EQ(4, ild(u"Aλ¶─")); } TEST(x86ild, test_41C6042400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [r12], 0x0 */ EXPECT_EQ(5, ild(u"A╞♦$ ")); } TEST(x86ild, test_41C60000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_IMMb ISA_SET: I86 SHORT: mov byte ptr [r8], 0x0 */ EXPECT_EQ(4, ild(u"A╞  ")); } TEST(x86ild, test_418B8000000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_MEMv ISA_SET: I86 SHORT: mov eax, dword ptr [r8] */ EXPECT_EQ(7, ild(u"AïÇ    ")); } TEST(x86ild, test_418A0C14) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov cl, byte ptr [r12+rdx*1] */ EXPECT_EQ(4, ild(u"Aè♀¶")); } TEST(x86ild, test_418A0404) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [r12+rax*1] */ EXPECT_EQ(4, ild(u"Aè♦♦")); } TEST(x86ild, test_418A0400) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov al, byte ptr [r8+rax*1] */ EXPECT_EQ(4, ild(u"Aè♦ ")); } TEST(x86ild, test_4189FB) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r11d, edi */ EXPECT_EQ(3, ild(u"Aë√")); } TEST(x86ild, test_4189F8) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r8d, edi */ EXPECT_EQ(3, ild(u"Aë°")); } TEST(x86ild, test_4189DC) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r12d, ebx */ EXPECT_EQ(3, ild(u"Aë▄")); } TEST(x86ild, test_4189D7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r15d, edx */ EXPECT_EQ(3, ild(u"Aë╫")); } TEST(x86ild, test_4189D6) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r14d, edx */ EXPECT_EQ(3, ild(u"Aë╓")); } TEST(x86ild, test_4189D3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r11d, edx */ EXPECT_EQ(3, ild(u"Aë╙")); } TEST(x86ild, test_4189CB) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r11d, ecx */ EXPECT_EQ(3, ild(u"Aë╦")); } TEST(x86ild, test_4189C1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r9d, eax */ EXPECT_EQ(3, ild(u"Aë┴")); } TEST(x86ild, test_4189C0) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPRv_GPRv_89 ISA_SET: I86 SHORT: mov r8d, eax */ EXPECT_EQ(3, ild(u"Aë└")); } TEST(x86ild, test_41898800000000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMv_GPRv ISA_SET: I86 SHORT: mov dword ptr [r8], ecx */ EXPECT_EQ(7, ild(u"Aëê    ")); } TEST(x86ild, test_4188F2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r10b, sil */ EXPECT_EQ(3, ild(u"Aê≥")); } TEST(x86ild, test_4188CE) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r14b, cl */ EXPECT_EQ(3, ild(u"Aê╬")); } TEST(x86ild, test_4188C3) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r11b, al */ EXPECT_EQ(3, ild(u"Aê├")); } TEST(x86ild, test_4188C2) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r10b, al */ EXPECT_EQ(3, ild(u"Aê┬")); } TEST(x86ild, test_4188C1) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov r9b, al */ EXPECT_EQ(3, ild(u"Aê┴")); } TEST(x86ild, test_41885000) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [r8], dl */ EXPECT_EQ(4, ild(u"AêP ")); } TEST(x86ild, test_4158) { /* ICLASS: POP CATEGORY: POP EXTENSION: BASE IFORM: POP_GPRv_58 ISA_SET: I86 SHORT: pop r8 */ EXPECT_EQ(2, ild(u"AX")); } TEST(x86ild, test_40B600) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_IMMb_B0 ISA_SET: I86 SHORT: mov sil, 0x0 */ EXPECT_EQ(3, ild(u"@╢ ")); } TEST(x86ild, test_408A7D00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_MEMb ISA_SET: I86 SHORT: mov dil, byte ptr [rbp] */ EXPECT_EQ(4, ild(u"@è} ")); } TEST(x86ild, test_4088FA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dl, dil */ EXPECT_EQ(3, ild(u"@ê·")); } TEST(x86ild, test_4088EA) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dl, bpl */ EXPECT_EQ(3, ild(u"@êΩ")); } TEST(x86ild, test_4088D7) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov dil, dl */ EXPECT_EQ(3, ild(u"@ê╫")); } TEST(x86ild, test_4088C5) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_GPR8_GPR8_88 ISA_SET: I86 SHORT: mov bpl, al */ EXPECT_EQ(3, ild(u"@ê┼")); } TEST(x86ild, test_40887B00) { /* ICLASS: MOV CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOV_MEMb_GPR8 ISA_SET: I86 SHORT: mov byte ptr [rbx], dil */ EXPECT_EQ(4, ild(u"@ê{ ")); } TEST(x86ild, test_0F8E00000000) { /* ICLASS: JLE CATEGORY: COND_BR EXTENSION: BASE IFORM: JLE_RELBRd ISA_SET: I86 SHORT: jle 0x6 */ EXPECT_EQ(6, ild(u"☼Ä    ")); } TEST(x86ild, test_0F8800000000) { /* ICLASS: JS CATEGORY: COND_BR EXTENSION: BASE IFORM: JS_RELBRd ISA_SET: I86 SHORT: js 0x6 */ EXPECT_EQ(6, ild(u"☼ê    ")); } TEST(x86ild, test_0F8200000000) { /* ICLASS: JB CATEGORY: COND_BR EXTENSION: BASE IFORM: JB_RELBRd ISA_SET: I86 SHORT: jb 0x6 */ EXPECT_EQ(6, ild(u"☼é    ")); }
66,980
3,742
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_popular_misc_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" TEST(x86ild, test_488D7300) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rbx] */ ASSERT_EQ(4, ild(u"Hìs ")); } TEST(x86ild, test_488D0480) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rax+rax*4] */ ASSERT_EQ(4, ild(u"Hì♦Ç")); } TEST(x86ild, test_488D0440) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rax+rax*2] */ ASSERT_EQ(4, ild(u"Hì♦@")); } TEST(x86ild, test_8D148500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax*4] */ ASSERT_EQ(7, ild(u"ì¶à    ")); } TEST(x86ild, test_488D5000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rax] */ ASSERT_EQ(4, ild(u"HìP ")); } TEST(x86ild, test_488D1492) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rdx+rdx*4] */ ASSERT_EQ(4, ild(u"Hì¶Æ")); } TEST(x86ild, test_8D348D00000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [rcx*4] */ ASSERT_EQ(7, ild(u"ì4ì    ")); } TEST(x86ild, test_8D34CD00000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [rcx*8] */ ASSERT_EQ(7, ild(u"ì4═    ")); } TEST(x86ild, test_8D0C8500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rax*4] */ ASSERT_EQ(7, ild(u"ì♀à    ")); } TEST(x86ild, test_8D1400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax+rax*1] */ ASSERT_EQ(3, ild(u"춠")); } TEST(x86ild, test_488D1401) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rcx+rax*1] */ ASSERT_EQ(4, ild(u"Hì¶☺")); } TEST(x86ild, test_488D14D2) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rdx+rdx*8] */ ASSERT_EQ(4, ild(u"Hì¶╥")); } TEST(x86ild, test_488D1452) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rdx+rdx*2] */ ASSERT_EQ(4, ild(u"Hì¶R")); } TEST(x86ild, test_488D9000000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rax] */ ASSERT_EQ(7, ild(u"HìÉ    ")); } TEST(x86ild, test_488D04C0) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rax+rax*8] */ ASSERT_EQ(4, ild(u"Hì♦└")); } TEST(x86ild, test_8D0CC500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rax*8] */ ASSERT_EQ(7, ild(u"ì♀┼    ")); } TEST(x86ild, test_488D8800000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rcx, ptr [rax] */ ASSERT_EQ(7, ild(u"Hìê    ")); } TEST(x86ild, test_488D0C16) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rcx, ptr [rsi+rdx*1] */ ASSERT_EQ(4, ild(u"Hì♀▬")); } TEST(x86ild, test_488D742400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rsp] */ ASSERT_EQ(5, ild(u"Hìt$ ")); } TEST(x86ild, test_488D7C2400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdi, ptr [rsp] */ ASSERT_EQ(5, ild(u"Hì|$ ")); } TEST(x86ild, test_8D540200) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rdx+rax*1] */ ASSERT_EQ(4, ild(u"ìT☻ ")); } TEST(x86ild, test_488D0452) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rdx+rdx*2] */ ASSERT_EQ(4, ild(u"Hì♦R")); } TEST(x86ild, test_8D54D000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax+rdx*8] */ ASSERT_EQ(4, ild(u"ìT╨ ")); } TEST(x86ild, test_8D14C500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax*8] */ ASSERT_EQ(7, ild(u"ì¶┼    ")); } TEST(x86ild, test_488D4800) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rcx, ptr [rax] */ ASSERT_EQ(4, ild(u"HìH ")); } TEST(x86ild, test_488D0C10) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rcx, ptr [rax+rdx*1] */ ASSERT_EQ(4, ild(u"Hì♀►")); } TEST(x86ild, test_8D14D0) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax+rdx*8] */ ASSERT_EQ(3, ild(u"ì¶╨")); } TEST(x86ild, test_498D3408) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [r8+rcx*1] */ ASSERT_EQ(4, ild(u"Iì4◘")); } TEST(x86ild, test_488D340A) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rdx+rcx*1] */ ASSERT_EQ(4, ild(u"Hì4◙")); } TEST(x86ild, test_8D5500) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rbp] */ ASSERT_EQ(3, ild(u"ìU ")); } TEST(x86ild, test_8D349500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [rdx*4] */ ASSERT_EQ(7, ild(u"ì4ò    ")); } TEST(x86ild, test_488DB000000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rax] */ ASSERT_EQ(7, ild(u"Hì░    ")); } TEST(x86ild, test_8D541000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax+rdx*1] */ ASSERT_EQ(4, ild(u"ìT► ")); } TEST(x86ild, test_8D4200) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rdx] */ ASSERT_EQ(3, ild(u"ìB ")); } TEST(x86ild, test_8D3CF500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edi, ptr [rsi*8] */ ASSERT_EQ(7, ild(u"ì<⌡    ")); } TEST(x86ild, test_8D3409) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [rcx+rcx*1] */ ASSERT_EQ(3, ild(u"ì4○")); } TEST(x86ild, test_8D0C00) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rax+rax*1] */ ASSERT_EQ(3, ild(u"ì♀ ")); } TEST(x86ild, test_8D0448) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rax+rcx*2] */ ASSERT_EQ(3, ild(u"ì♦H")); } TEST(x86ild, test_488D542400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rsp] */ ASSERT_EQ(5, ild(u"HìT$ ")); } TEST(x86ild, test_8D5000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax] */ ASSERT_EQ(3, ild(u"ìP ")); } TEST(x86ild, test_8D1450) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax+rdx*2] */ ASSERT_EQ(3, ild(u"ì¶P")); } TEST(x86ild, test_8D0490) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rax+rdx*4] */ ASSERT_EQ(3, ild(u"ì♦É")); } TEST(x86ild, test_4C8D0431) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8, ptr [rcx+rsi*1] */ ASSERT_EQ(4, ild(u"Lì♦1")); } TEST(x86ild, test_488DB100000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rcx] */ ASSERT_EQ(7, ild(u"Hì▒    ")); } TEST(x86ild, test_8D4E00) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rsi] */ ASSERT_EQ(3, ild(u"ìN ")); } TEST(x86ild, test_8D440200) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rdx+rax*1] */ ASSERT_EQ(4, ild(u"ìD☻ ")); } TEST(x86ild, test_8D1490) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax+rdx*4] */ ASSERT_EQ(3, ild(u"ì¶É")); } TEST(x86ild, test_8D1482) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rdx+rax*4] */ ASSERT_EQ(3, ild(u"ì¶é")); } TEST(x86ild, test_8D1401) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rcx+rax*1] */ ASSERT_EQ(3, ild(u"ì¶☺")); } TEST(x86ild, test_8D0412) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rdx+rdx*1] */ ASSERT_EQ(3, ild(u"ì♦↕")); } TEST(x86ild, test_4C8D0416) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8, ptr [rsi+rdx*1] */ ASSERT_EQ(4, ild(u"Lì♦▬")); } TEST(x86ild, test_498D1430) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [r8+rsi*1] */ ASSERT_EQ(4, ild(u"Iì¶0")); } TEST(x86ild, test_488D8A00000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rcx, ptr [rdx] */ ASSERT_EQ(7, ild(u"Hìè    ")); } TEST(x86ild, test_488D4700) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rdi] */ ASSERT_EQ(4, ild(u"HìG ")); } TEST(x86ild, test_488D340E) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rsi+rcx*1] */ ASSERT_EQ(4, ild(u"Hì4♫")); } TEST(x86ild, test_488D3401) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rcx+rax*1] */ ASSERT_EQ(4, ild(u"Hì4☺")); } TEST(x86ild, test_488D1431) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rcx+rsi*1] */ ASSERT_EQ(4, ild(u"Hì¶1")); } TEST(x86ild, test_488D0C49) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rcx, ptr [rcx+rcx*2] */ ASSERT_EQ(4, ild(u"Hì♀I")); } TEST(x86ild, test_488D048500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rax*4] */ ASSERT_EQ(8, ild(u"Hì♦à    ")); } TEST(x86ild, test_488D040E) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rsi+rcx*1] */ ASSERT_EQ(4, ild(u"Hì♦♫")); } TEST(x86ild, test_8D9300000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rbx] */ ASSERT_EQ(6, ild(u"ìô    ")); } TEST(x86ild, test_8D7900) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edi, ptr [rcx] */ ASSERT_EQ(3, ild(u"ìy ")); } TEST(x86ild, test_8D5600) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rsi] */ ASSERT_EQ(3, ild(u"ìV ")); } TEST(x86ild, test_8D545000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rax+rdx*2] */ ASSERT_EQ(4, ild(u"ìTP ")); } TEST(x86ild, test_8D4800) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rax] */ ASSERT_EQ(3, ild(u"ìH ")); } TEST(x86ild, test_8D4700) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rdi] */ ASSERT_EQ(3, ild(u"ìG ")); } TEST(x86ild, test_8D4600) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rsi] */ ASSERT_EQ(3, ild(u"ìF ")); } TEST(x86ild, test_8D0CF500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rsi*8] */ ASSERT_EQ(7, ild(u"ì♀⌡    ")); } TEST(x86ild, test_8D0CB500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rsi*4] */ ASSERT_EQ(7, ild(u"ì♀╡    ")); } TEST(x86ild, test_8D0C9500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rdx*4] */ ASSERT_EQ(7, ild(u"ì♀ò    ")); } TEST(x86ild, test_8D04B500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rsi*4] */ ASSERT_EQ(7, ild(u"ì♦╡    ")); } TEST(x86ild, test_4F8D0C49) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r9, ptr [r9+r9*2] */ ASSERT_EQ(4, ild(u"Oì♀I")); } TEST(x86ild, test_498D7C2400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdi, ptr [r12] */ ASSERT_EQ(5, ild(u"Iì|$ ")); } TEST(x86ild, test_488DB800000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdi, ptr [rax] */ ASSERT_EQ(7, ild(u"Hì╕    ")); } TEST(x86ild, test_488D4C2400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rcx, ptr [rsp] */ ASSERT_EQ(5, ild(u"HìL$ ")); } TEST(x86ild, test_488D442400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rsp] */ ASSERT_EQ(5, ild(u"HìD$ ")); } TEST(x86ild, test_488D3CC500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdi, ptr [rax*8] */ ASSERT_EQ(8, ild(u"Hì<┼    ")); } TEST(x86ild, test_488D3402) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rdx+rax*1] */ ASSERT_EQ(4, ild(u"Hì4☻")); } TEST(x86ild, test_488D040A) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rdx+rcx*1] */ ASSERT_EQ(4, ild(u"Hì♦◙")); } TEST(x86ild, test_488D0408) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rax+rcx*1] */ ASSERT_EQ(4, ild(u"Hì♦◘")); } TEST(x86ild, test_448D4100) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8d, ptr [rcx] */ ASSERT_EQ(4, ild(u"DìA ")); } TEST(x86ild, test_418D442400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [r12] */ ASSERT_EQ(5, ild(u"AìD$ ")); } TEST(x86ild, test_8D8A00000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rdx] */ ASSERT_EQ(6, ild(u"ìè    ")); } TEST(x86ild, test_8D8300000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rbx] */ ASSERT_EQ(6, ild(u"ìâ    ")); } TEST(x86ild, test_8D7100) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [rcx] */ ASSERT_EQ(3, ild(u"ìq ")); } TEST(x86ild, test_8D4D00) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rbp] */ ASSERT_EQ(3, ild(u"ìM ")); } TEST(x86ild, test_8D4500) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rbp] */ ASSERT_EQ(3, ild(u"ìE ")); } TEST(x86ild, test_8D44F000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rax+rsi*8] */ ASSERT_EQ(4, ild(u"ìD≡ ")); } TEST(x86ild, test_8D449000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rax+rdx*4] */ ASSERT_EQ(4, ild(u"ìDÉ ")); } TEST(x86ild, test_8D441500) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rbp+rdx*1] */ ASSERT_EQ(4, ild(u"ìD§ ")); } TEST(x86ild, test_8D440A00) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rdx+rcx*1] */ ASSERT_EQ(4, ild(u"ìD◙ ")); } TEST(x86ild, test_8D440100) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rcx+rax*1] */ ASSERT_EQ(4, ild(u"ìD☺ ")); } TEST(x86ild, test_8D4100) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rcx] */ ASSERT_EQ(3, ild(u"ìA ")); } TEST(x86ild, test_8D3CB500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edi, ptr [rsi*4] */ ASSERT_EQ(7, ild(u"ì<╡    ")); } TEST(x86ild, test_8D34D500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [rdx*8] */ ASSERT_EQ(7, ild(u"ì4╒    ")); } TEST(x86ild, test_8D34C500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [rax*8] */ ASSERT_EQ(7, ild(u"ì4┼    ")); } TEST(x86ild, test_8D3412) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [rdx+rdx*1] */ ASSERT_EQ(3, ild(u"ì4↕")); } TEST(x86ild, test_8D14F500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rsi*8] */ ASSERT_EQ(7, ild(u"ì¶⌡    ")); } TEST(x86ild, test_8D14BD00000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rdi*4] */ ASSERT_EQ(7, ild(u"ì¶╜    ")); } TEST(x86ild, test_8D1451) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [rcx+rdx*2] */ ASSERT_EQ(3, ild(u"ì¶Q")); } TEST(x86ild, test_8D0CD500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [rdx*8] */ ASSERT_EQ(7, ild(u"ì♀╒    ")); } TEST(x86ild, test_8D04FD00000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rdi*8] */ ASSERT_EQ(7, ild(u"ì♦²    ")); } TEST(x86ild, test_8D049500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rdx*4] */ ASSERT_EQ(7, ild(u"ì♦ò    ")); } TEST(x86ild, test_8D0488) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rax+rcx*4] */ ASSERT_EQ(3, ild(u"ì♦ê")); } TEST(x86ild, test_8D0409) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [rcx+rcx*1] */ ASSERT_EQ(3, ild(u"ì♦○")); } TEST(x86ild, test_4E8D0C06) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r9, ptr [rsi+r8*1] */ ASSERT_EQ(4, ild(u"Nì♀♠")); } TEST(x86ild, test_4D8D6C2400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r13, ptr [r12] */ ASSERT_EQ(5, ild(u"Mìl$ ")); } TEST(x86ild, test_4D8D0431) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8, ptr [r9+rsi*1] */ ASSERT_EQ(4, ild(u"Mì♦1")); } TEST(x86ild, test_4C8D642400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r12, ptr [rsp] */ ASSERT_EQ(5, ild(u"Lìd$ ")); } TEST(x86ild, test_4C8D4100) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8, ptr [rcx] */ ASSERT_EQ(4, ild(u"LìA ")); } TEST(x86ild, test_4C8D0C19) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r9, ptr [rcx+rbx*1] */ ASSERT_EQ(4, ild(u"Lì♀↓")); } TEST(x86ild, test_4C8D0402) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8, ptr [rdx+rax*1] */ ASSERT_EQ(4, ild(u"Lì♦☻")); } TEST(x86ild, test_4A8D0C07) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rcx, ptr [rdi+r8*1] */ ASSERT_EQ(4, ild(u"Jì♀•")); } TEST(x86ild, test_488DA800000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rbp, ptr [rax] */ ASSERT_EQ(7, ild(u"Hì¿    ")); } TEST(x86ild, test_488D5700) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rdi] */ ASSERT_EQ(4, ild(u"HìW ")); } TEST(x86ild, test_488D4200) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rdx] */ ASSERT_EQ(4, ild(u"HìB ")); } TEST(x86ild, test_488D3C7F) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdi, ptr [rdi+rdi*2] */ ASSERT_EQ(4, ild(u"Hì<⌂")); } TEST(x86ild, test_488D3500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rip] */ ASSERT_EQ(7, ild(u"Hì5    ")); } TEST(x86ild, test_488D34F7) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rdi+rsi*8] */ ASSERT_EQ(4, ild(u"Hì4≈")); } TEST(x86ild, test_488D3476) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rsi+rsi*2] */ ASSERT_EQ(4, ild(u"Hì4v")); } TEST(x86ild, test_488D3410) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rax+rdx*1] */ ASSERT_EQ(4, ild(u"Hì4►")); } TEST(x86ild, test_488D3408) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rsi, ptr [rax+rcx*1] */ ASSERT_EQ(4, ild(u"Hì4◘")); } TEST(x86ild, test_488D2CD500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rbp, ptr [rdx*8] */ ASSERT_EQ(8, ild(u"Hì,╒    ")); } TEST(x86ild, test_488D14B0) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rax+rsi*4] */ ASSERT_EQ(4, ild(u"Hì¶░")); } TEST(x86ild, test_488D1496) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rsi+rdx*4] */ ASSERT_EQ(4, ild(u"Hì¶û")); } TEST(x86ild, test_488D1406) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rdx, ptr [rsi+rax*1] */ ASSERT_EQ(4, ild(u"Hì¶♠")); } TEST(x86ild, test_488D0C02) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rcx, ptr [rdx+rax*1] */ ASSERT_EQ(4, ild(u"Hì♀☻")); } TEST(x86ild, test_488D04FD00000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rdi*8] */ ASSERT_EQ(8, ild(u"Hì♦²    ")); } TEST(x86ild, test_488D04F500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rsi*8] */ ASSERT_EQ(8, ild(u"Hì♦⌡    ")); } TEST(x86ild, test_488D04CD00000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rcx*8] */ ASSERT_EQ(8, ild(u"Hì♦═    ")); } TEST(x86ild, test_488D04B0) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rax+rsi*4] */ ASSERT_EQ(4, ild(u"Hì♦░")); } TEST(x86ild, test_488D049500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rdx*4] */ ASSERT_EQ(8, ild(u"Hì♦ò    ")); } TEST(x86ild, test_488D0486) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rsi+rax*4] */ ASSERT_EQ(4, ild(u"Hì♦å")); } TEST(x86ild, test_488D0482) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rdx+rax*4] */ ASSERT_EQ(4, ild(u"Hì♦é")); } TEST(x86ild, test_488D0430) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea rax, ptr [rax+rsi*1] */ ASSERT_EQ(4, ild(u"Hì♦0")); } TEST(x86ild, test_468D240A) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r12d, ptr [rdx+r9*1] */ ASSERT_EQ(4, ild(u"Fì$◙")); } TEST(x86ild, test_468D0CD500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r9d, ptr [r10*8] */ ASSERT_EQ(8, ild(u"Fì♀╒    ")); } TEST(x86ild, test_468D0CC500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r9d, ptr [r8*8] */ ASSERT_EQ(8, ild(u"Fì♀┼    ")); } TEST(x86ild, test_468D0C06) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r9d, ptr [rsi+r8*1] */ ASSERT_EQ(4, ild(u"Fì♀♠")); } TEST(x86ild, test_458D7E00) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r15d, ptr [r14] */ ASSERT_EQ(4, ild(u"Eì~ ")); } TEST(x86ild, test_458D3401) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r14d, ptr [r9+rax*1] */ ASSERT_EQ(4, ild(u"Eì4☺")); } TEST(x86ild, test_448D7000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r14d, ptr [rax] */ ASSERT_EQ(4, ild(u"Dìp ")); } TEST(x86ild, test_448D4800) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r9d, ptr [rax] */ ASSERT_EQ(4, ild(u"DìH ")); } TEST(x86ild, test_448D4600) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8d, ptr [rsi] */ ASSERT_EQ(4, ild(u"DìF ")); } TEST(x86ild, test_448D14C500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r10d, ptr [rax*8] */ ASSERT_EQ(8, ild(u"Dì¶┼    ")); } TEST(x86ild, test_448D148500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r10d, ptr [rax*4] */ ASSERT_EQ(8, ild(u"Dì¶à    ")); } TEST(x86ild, test_448D04F500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8d, ptr [rsi*8] */ ASSERT_EQ(8, ild(u"Dì♦⌡    ")); } TEST(x86ild, test_448D04B500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8d, ptr [rsi*4] */ ASSERT_EQ(8, ild(u"Dì♦╡    ")); } TEST(x86ild, test_448D043F) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea r8d, ptr [rdi+rdi*1] */ ASSERT_EQ(4, ild(u"Dì♦⁇")); } TEST(x86ild, test_428D34C500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [r8*8] */ ASSERT_EQ(8, ild(u"Bì4┼    ")); } TEST(x86ild, test_428D348500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [r8*4] */ ASSERT_EQ(8, ild(u"Bì4à    ")); } TEST(x86ild, test_428D2C30) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ebp, ptr [rax+r14*1] */ ASSERT_EQ(4, ild(u"Bì,0")); } TEST(x86ild, test_428D0CB500000000) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [r14*4] */ ASSERT_EQ(8, ild(u"Bì♀╡    ")); } TEST(x86ild, test_418D741500) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea esi, ptr [r13+rdx*1] */ ASSERT_EQ(5, ild(u"Aìt§ ")); } TEST(x86ild, test_418D6B00) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ebp, ptr [r11] */ ASSERT_EQ(4, ild(u"Aìk ")); } TEST(x86ild, test_418D5600) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea edx, ptr [r14] */ ASSERT_EQ(4, ild(u"AìV ")); } TEST(x86ild, test_418D4C2400) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea ecx, ptr [r12] */ ASSERT_EQ(5, ild(u"AìL$ ")); } TEST(x86ild, test_418D4700) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [r15] */ ASSERT_EQ(4, ild(u"AìG ")); } TEST(x86ild, test_418D440C00) { /* ICLASS: LEA CATEGORY: MISC EXTENSION: BASE IFORM: LEA_GPRv_AGEN ISA_SET: I86 SHORT: lea eax, ptr [r12+rcx*1] */ ASSERT_EQ(5, ild(u"AìD♀ ")); }
35,343
1,930
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/gc.internal.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" /** * @fileoverview Instruction Length Decoding Tests. * * It is demonstrated that our 3.5kb x86 parser supports all legal x86 * instruction set architectures and addressing modes since the 1970's, * including the really sophisticated ones, e.g. avx512, as well as the * less popular ones, e.g. 3dnow. */ TEST(x86ild, testSomeThingsNeverChange) { ASSERT_EQ(3, ildreal(u"â└↨")); /* add $23,%ax */ ASSERT_EQ(3, ildlegacy(u"â└↨")); /* add $23,%eax */ ASSERT_EQ(3, ild(u"â└↨")); /* add $23,%eax */ } TEST(x86ild, testSomeThingsDoChange) { ASSERT_EQ(3, ildreal(u"♣7‼ÉÉ")); /* add $0x1337,%ax */ ASSERT_EQ(5, ildlegacy(u"♣7‼ÉÉ")); /* add $0x90901337,%eax */ ASSERT_EQ(5, ild(u"♣7‼ÉÉ")); /* add $0x90901337,%eax */ ASSERT_EQ(1, ildreal(u"@É")); /* inc %ax */ ASSERT_EQ(1, ildlegacy(u"@É")); /* inc %eax */ ASSERT_EQ(2, ild(u"@É")); /* rex xchg %eax,%eax */ } TEST(x86ild, testHugeInstructions) { ASSERT_EQ(10, ild(u"H║       Ç")); /* movabs $0x8000000000000000,%rdx */ ASSERT_EQ(11, ild(u"H╟♣8l   É  ")); /* movq $0x209000,0x6c38(%rip) */ ASSERT_EQ(12, ild(u"H╟ä$á       ")); /* movq $0x0,0xa0(%rsp) */ } TEST(x86ild, testLaughOutLoudLargeCanonicalInstructions) { ASSERT_EQ(15, /* lock addl $0x12331337,%fs:-0x1337(%ebx,%esi,1) */ ildreal(u"≡dfgüä3╔∞λλ7‼3↕")); } TEST(x86ild, testEncodingDisagreements) { ASSERT_EQ(13, /* lock addw $0x1337,%fs:-0x1337(%ebx,%esi,1) */ ild(u"fg≡düä3╔∞λλ7‼")); /* ← xed encoding */ ASSERT_EQ(13, /* lock addw $0x1337,%fs:-0x1337(%ebx,%esi,1) */ ild(u"dgf≡üä3╔∞λλ7‼")); /* ← gas encoding */ } TEST(x86ild, testOverlongInstructions) { ASSERT_EQ(3, ild(u"≤≤É")); /* rep pause */ ASSERT_EQ(-XED_ERROR_BUFFER_TOO_SHORT /* suboptimal error code */, ildreal(u"≡≡≡≡dfgüä3╔∞λλ7‼3↕")); } TEST(x86ild, testAvx512_inRealMode_throwsError) { ASSERT_EQ(-XED_ERROR_INVALID_MODE, ildreal(u"bßTXYö∟¶♦  ")); } TEST(x86ild, testAvx512) { ASSERT_EQ(6, /* vaddps %zmm17,%zmm16,%zmm16 */ ild(u"b¡|@X┴")); ASSERT_EQ(11, /* vmulps 0x414(%rsp,%rbx,1){1to16},%zmm5,%zmm18 */ ild(u"bßTXYö∟¶♦  ")); } TEST(x86ild, testCascadeLake_advancedNeuralNetworkInstructions) { ASSERT_EQ(6, ild(u"b≥m◘P╦")); /* vpdpbusd %xmm3,%xmm2,%xmm1 */ ASSERT_EQ(11 /* vpdpbusd 0x10000000(%rcx,%r14,8),%xmm2,%xmm1 */, ild(u"b▓m◘Pî±   ►")); } TEST(x86ild, testAmd3dnow) { ASSERT_EQ(4, ild(u"☼☼╚ª")); /* pfrcpit1 %mm0,%mm1 */ struct XedDecodedInst xedd; ASSERT_EQ( 0, xed_instruction_length_decode( xed_decoded_inst_zero_set_mode(&xedd, XED_MACHINE_MODE_LEGACY_32), gc(unbingx86op(u"☼☼╚ª")), 4)); ASSERT_EQ(true, (int)xedd.op.amd3dnow); ASSERT_EQ(0xa6, xedd.op.opcode); } TEST(x86ild, testPopToMemory) { ASSERT_EQ(3, ild(u"ÅF◘")); /* 8f 46 08 */ } TEST(x86ild, testFinit) { ASSERT_EQ(1, ild(u"¢█π")); /* 9B DB E3: fwait */ ASSERT_EQ(2, ild(u"█π")); /* DB E3: fninit */ } BENCH(x86ild, bench) { uint8_t *x = gc(unbingx86op(u"b▓m◘Pî±   ►")); struct XedDecodedInst xedd; EZBENCH2("x86ild", donothing, xed_instruction_length_decode( xed_decoded_inst_zero_set_mode(&xedd, XED_MACHINE_MODE_LONG_64), x, XED_MAX_INSTRUCTION_BYTES)); }
5,491
118
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_popular_i386_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" /** * @fileoverview GCC's popular i386+ instruction w/ NexGen32e encoding. */ TEST(x86ild, test_400FB6C5) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx eax, bpl */ ASSERT_EQ(4, ild(u"@☼╢┼")); } TEST(x86ild, test_0FB6C0) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx eax, al */ ASSERT_EQ(3, ild(u"☼╢└")); } TEST(x86ild, test_0FB6E8) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx ebp, al */ ASSERT_EQ(3, ild(u"☼╢Φ")); } TEST(x86ild, test_0F95C0) { /* ICLASS: SETNZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETNZ_GPR8 ISA_SET: I386 SHORT: setnz al */ ASSERT_EQ(3, ild(u"☼ò└")); } TEST(x86ild, test_0F94C0) { /* ICLASS: SETZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETZ_GPR8 ISA_SET: I386 SHORT: setz al */ ASSERT_EQ(3, ild(u"☼ö└")); } TEST(x86ild, test_400FB6D5) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx edx, bpl */ ASSERT_EQ(4, ild(u"@☼╢╒")); } TEST(x86ild, test_0FB6D0) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx edx, al */ ASSERT_EQ(3, ild(u"☼╢╨")); } TEST(x86ild, test_0F95C2) { /* ICLASS: SETNZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETNZ_GPR8 ISA_SET: I386 SHORT: setnz dl */ ASSERT_EQ(3, ild(u"☼ò┬")); } TEST(x86ild, test_0F94C2) { /* ICLASS: SETZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETZ_GPR8 ISA_SET: I386 SHORT: setz dl */ ASSERT_EQ(3, ild(u"☼ö┬")); } TEST(x86ild, test_0FB6D2) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx edx, dl */ ASSERT_EQ(3, ild(u"☼╢╥")); } TEST(x86ild, test_0FBE841200000000) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx eax, byte ptr [rdx+rdx*1] */ ASSERT_EQ(8, ild(u"☼╛ä↕    ")); } TEST(x86ild, test_0FB64000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rax] */ ASSERT_EQ(4, ild(u"☼╢@ ")); } TEST(x86ild, test_0FBE04D500000000) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx eax, byte ptr [rdx*8] */ ASSERT_EQ(8, ild(u"☼╛♦╒    ")); } TEST(x86ild, test_0FBE8000000000) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx eax, byte ptr [rax] */ ASSERT_EQ(7, ild(u"☼╛Ç    ")); } TEST(x86ild, test_0FB64800) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ecx, byte ptr [rax] */ ASSERT_EQ(4, ild(u"☼╢H ")); } TEST(x86ild, test_0FB64700) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"☼╢G ")); } TEST(x86ild, test_0FB65700) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edx, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"☼╢W ")); } TEST(x86ild, test_0FB6C2) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx eax, dl */ ASSERT_EQ(3, ild(u"☼╢┬")); } TEST(x86ild, test_0FB67000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx esi, byte ptr [rax] */ ASSERT_EQ(4, ild(u"☼╢p ")); } TEST(x86ild, test_0FB68000000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rax] */ ASSERT_EQ(7, ild(u"☼╢Ç    ")); } TEST(x86ild, test_0FB6C9) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx ecx, cl */ ASSERT_EQ(3, ild(u"☼╢╔")); } TEST(x86ild, test_0FBE4100) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx eax, byte ptr [rcx] */ ASSERT_EQ(4, ild(u"☼╛A ")); } TEST(x86ild, test_0F94C1) { /* ICLASS: SETZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETZ_GPR8 ISA_SET: I386 SHORT: setz cl */ ASSERT_EQ(3, ild(u"☼ö┴")); } TEST(x86ild, test_0FB6841200000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rdx+rdx*1] */ ASSERT_EQ(8, ild(u"☼╢ä↕    ")); } TEST(x86ild, test_400FB6F6) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx esi, sil */ ASSERT_EQ(4, ild(u"@☼╢÷")); } TEST(x86ild, test_0FBAE500) { /* ICLASS: BT CATEGORY: BITBYTE EXTENSION: BASE IFORM: BT_GPRv_IMMb ISA_SET: I386 SHORT: bt ebp, 0x0 */ ASSERT_EQ(4, ild(u"☼║σ ")); } TEST(x86ild, test_0FB6C1) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx eax, cl */ ASSERT_EQ(3, ild(u"☼╢┴")); } TEST(x86ild, test_0FBE4600) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx eax, byte ptr [rsi] */ ASSERT_EQ(4, ild(u"☼╛F ")); } TEST(x86ild, test_0FB77800) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx edi, word ptr [rax] */ ASSERT_EQ(4, ild(u"☼╖x ")); } TEST(x86ild, test_0FB68700000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rdi] */ ASSERT_EQ(7, ild(u"☼╢ç    ")); } TEST(x86ild, test_0FB67F00) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edi, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"☼╢⌂ ")); } TEST(x86ild, test_0FB64F00) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ecx, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"☼╢O ")); } TEST(x86ild, test_0FB604D500000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rdx*8] */ ASSERT_EQ(8, ild(u"☼╢♦╒    ")); } TEST(x86ild, test_0FB78000000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx eax, word ptr [rax] */ ASSERT_EQ(7, ild(u"☼╖Ç    ")); } TEST(x86ild, test_0FB74700) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx eax, word ptr [rdi] */ ASSERT_EQ(4, ild(u"☼╖G ")); } TEST(x86ild, test_0F96C0) { /* ICLASS: SETBE CATEGORY: SETCC EXTENSION: BASE IFORM: SETBE_GPR8 ISA_SET: I386 SHORT: setbe al */ ASSERT_EQ(3, ild(u"☼û└")); } TEST(x86ild, test_0FB74500) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx eax, word ptr [rbp] */ ASSERT_EQ(4, ild(u"☼╖E ")); } TEST(x86ild, test_0FB6C8) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx ecx, al */ ASSERT_EQ(3, ild(u"☼╢╚")); } TEST(x86ild, test_440FB67500) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r14d, byte ptr [rbp] */ ASSERT_EQ(5, ild(u"D☼╢u ")); } TEST(x86ild, test_0FBE5600) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx edx, byte ptr [rsi] */ ASSERT_EQ(4, ild(u"☼╛V ")); } TEST(x86ild, test_0FB7F6) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR16 ISA_SET: I386 SHORT: movzx esi, si */ ASSERT_EQ(3, ild(u"☼╖÷")); } TEST(x86ild, test_0FB7840000000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx eax, word ptr [rax+rax*1] */ ASSERT_EQ(8, ild(u"☼╖ä     ")); } TEST(x86ild, test_0FB67D00) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edi, byte ptr [rbp] */ ASSERT_EQ(4, ild(u"☼╢} ")); } TEST(x86ild, test_0FB64B00) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ecx, byte ptr [rbx] */ ASSERT_EQ(4, ild(u"☼╢K ")); } TEST(x86ild, test_0FB64300) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rbx] */ ASSERT_EQ(4, ild(u"☼╢C ")); } TEST(x86ild, test_0FB64100) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rcx] */ ASSERT_EQ(4, ild(u"☼╢A ")); } TEST(x86ild, test_F3AB) { /* ICLASS: REP_STOSD CATEGORY: STRINGOP EXTENSION: BASE IFORM: REP_STOSD ISA_SET: I386 SHORT: rep stosd dword ptr [rdi] */ ASSERT_EQ(2, ild(u"≤½")); } TEST(x86ild, test_480FBE04D500000000) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx rax, byte ptr [rdx*8] */ ASSERT_EQ(9, ild(u"H☼╛♦╒    ")); } TEST(x86ild, test_400FB6CD) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx ecx, bpl */ ASSERT_EQ(4, ild(u"@☼╢═")); } TEST(x86ild, test_400FB6C7) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx eax, dil */ ASSERT_EQ(4, ild(u"@☼╢╟")); } TEST(x86ild, test_0FBE4E00) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx ecx, byte ptr [rsi] */ ASSERT_EQ(4, ild(u"☼╛N ")); } TEST(x86ild, test_0FBE0CD500000000) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx ecx, byte ptr [rdx*8] */ ASSERT_EQ(8, ild(u"☼╛♀╒    ")); } TEST(x86ild, test_0FB7C0) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR16 ISA_SET: I386 SHORT: movzx eax, ax */ ASSERT_EQ(3, ild(u"☼╖└")); } TEST(x86ild, test_0FB6CA) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx ecx, dl */ ASSERT_EQ(3, ild(u"☼╢╩")); } TEST(x86ild, test_0FB68200000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rdx] */ ASSERT_EQ(7, ild(u"☼╢é    ")); } TEST(x86ild, test_0FB67300) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx esi, byte ptr [rbx] */ ASSERT_EQ(4, ild(u"☼╢s ")); } TEST(x86ild, test_0FB65300) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edx, byte ptr [rbx] */ ASSERT_EQ(4, ild(u"☼╢S ")); } TEST(x86ild, test_450FB6C0) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx r8d, r8b */ ASSERT_EQ(4, ild(u"E☼╢└")); } TEST(x86ild, test_0FBE8100000000) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx eax, byte ptr [rcx] */ ASSERT_EQ(7, ild(u"☼╛ü    ")); } TEST(x86ild, test_0FBE4F00) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx ecx, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"☼╛O ")); } TEST(x86ild, test_0FBE4700) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx eax, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"☼╛G ")); } TEST(x86ild, test_0FBE049500000000) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx eax, byte ptr [rdx*4] */ ASSERT_EQ(8, ild(u"☼╛♦ò    ")); } TEST(x86ild, test_0FB7C7) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR16 ISA_SET: I386 SHORT: movzx eax, di */ ASSERT_EQ(3, ild(u"☼╖╟")); } TEST(x86ild, test_0FB75700) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx edx, word ptr [rdi] */ ASSERT_EQ(4, ild(u"☼╖W ")); } TEST(x86ild, test_0FB6742400) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx esi, byte ptr [rsp] */ ASSERT_EQ(5, ild(u"☼╢t$ ")); } TEST(x86ild, test_0FB630) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx esi, byte ptr [rax] */ ASSERT_EQ(3, ild(u"☼╢0")); } TEST(x86ild, test_0FB62F) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ebp, byte ptr [rdi] */ ASSERT_EQ(3, ild(u"☼╢/")); } TEST(x86ild, test_0FB600) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rax] */ ASSERT_EQ(3, ild(u"☼╢ ")); } TEST(x86ild, test_66400FBEC7) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_GPR8 ISA_SET: I386 SHORT: movsx ax, dil */ ASSERT_EQ(5, ild(u"f@☼╛╟")); } TEST(x86ild, test_480FBFF6) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_GPR16 ISA_SET: I386 SHORT: movsx rsi, si */ ASSERT_EQ(4, ild(u"H☼┐÷")); } TEST(x86ild, test_480FBFC7) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_GPR16 ISA_SET: I386 SHORT: movsx rax, di */ ASSERT_EQ(4, ild(u"H☼┐╟")); } TEST(x86ild, test_480FBF12) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMw ISA_SET: I386 SHORT: movsx rdx, word ptr [rdx] */ ASSERT_EQ(4, ild(u"H☼┐↕")); } TEST(x86ild, test_480FBEF6) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_GPR8 ISA_SET: I386 SHORT: movsx rsi, sil */ ASSERT_EQ(4, ild(u"H☼╛÷")); } TEST(x86ild, test_480FBEC7) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_GPR8 ISA_SET: I386 SHORT: movsx rax, dil */ ASSERT_EQ(4, ild(u"H☼╛╟")); } TEST(x86ild, test_480FBE12) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx rdx, byte ptr [rdx] */ ASSERT_EQ(4, ild(u"H☼╛↕")); } TEST(x86ild, test_480FA3D1) { /* ICLASS: BT CATEGORY: BITBYTE EXTENSION: BASE IFORM: BT_GPRv_GPRv ISA_SET: I386 SHORT: bt rcx, rdx */ ASSERT_EQ(4, ild(u"H☼ú╤")); } TEST(x86ild, test_480FA3D0) { /* ICLASS: BT CATEGORY: BITBYTE EXTENSION: BASE IFORM: BT_GPRv_GPRv ISA_SET: I386 SHORT: bt rax, rdx */ ASSERT_EQ(4, ild(u"H☼ú╨")); } TEST(x86ild, test_480FA3CE) { /* ICLASS: BT CATEGORY: BITBYTE EXTENSION: BASE IFORM: BT_GPRv_GPRv ISA_SET: I386 SHORT: bt rsi, rcx */ ASSERT_EQ(4, ild(u"H☼ú╬")); } TEST(x86ild, test_450FB7C0) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR16 ISA_SET: I386 SHORT: movzx r8d, r8w */ ASSERT_EQ(4, ild(u"E☼╖└")); } TEST(x86ild, test_450FB67500) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r14d, byte ptr [r13] */ ASSERT_EQ(5, ild(u"E☼╢u ")); } TEST(x86ild, test_450FB63424) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r14d, byte ptr [r12] */ ASSERT_EQ(5, ild(u"E☼╢4$")); } TEST(x86ild, test_450FB60C00) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r9d, byte ptr [r8+rax*1] */ ASSERT_EQ(5, ild(u"E☼╢♀ ")); } TEST(x86ild, test_440FB66B00) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r13d, byte ptr [rbx] */ ASSERT_EQ(5, ild(u"D☼╢k ")); } TEST(x86ild, test_440FB64700) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r8d, byte ptr [rdi] */ ASSERT_EQ(5, ild(u"D☼╢G ")); } TEST(x86ild, test_440FB62F) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r13d, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"D☼╢/")); } TEST(x86ild, test_440FB62C08) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r13d, byte ptr [rax+rcx*1] */ ASSERT_EQ(5, ild(u"D☼╢,◘")); } TEST(x86ild, test_440FB627) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r12d, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"D☼╢‘")); } TEST(x86ild, test_440FB62430) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r12d, byte ptr [rax+rsi*1] */ ASSERT_EQ(5, ild(u"D☼╢$0")); } TEST(x86ild, test_440FB620) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r12d, byte ptr [rax] */ ASSERT_EQ(4, ild(u"D☼╢ ")); } TEST(x86ild, test_440FB607) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx r8d, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"D☼╢•")); } TEST(x86ild, test_410FB7442400) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx eax, word ptr [r12] */ ASSERT_EQ(6, ild(u"A☼╖D$ ")); } TEST(x86ild, test_410FB67C2C00) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edi, byte ptr [r12+rbp*1] */ ASSERT_EQ(6, ild(u"A☼╢|, ")); } TEST(x86ild, test_410FB6442400) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [r12] */ ASSERT_EQ(6, ild(u"A☼╢D$ ")); } TEST(x86ild, test_410FB63400) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx esi, byte ptr [r8+rax*1] */ ASSERT_EQ(5, ild(u"A☼╢4 ")); } TEST(x86ild, test_410FB62C10) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ebp, byte ptr [r8+rdx*1] */ ASSERT_EQ(5, ild(u"A☼╢,►")); } TEST(x86ild, test_410F95C4) { /* ICLASS: SETNZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETNZ_GPR8 ISA_SET: I386 SHORT: setnz r12b */ ASSERT_EQ(4, ild(u"A☼ò─")); } TEST(x86ild, test_410F94C0) { /* ICLASS: SETZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETZ_GPR8 ISA_SET: I386 SHORT: setz r8b */ ASSERT_EQ(4, ild(u"A☼ö└")); } TEST(x86ild, test_400FBEC7) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_GPR8 ISA_SET: I386 SHORT: movsx eax, dil */ ASSERT_EQ(4, ild(u"@☼╛╟")); } TEST(x86ild, test_400FB6FF) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx edi, dil */ ASSERT_EQ(4, ild(u"@☼╢λ")); } TEST(x86ild, test_400FB6CE) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx ecx, sil */ ASSERT_EQ(4, ild(u"@☼╢╬")); } TEST(x86ild, test_400F9EC5) { /* ICLASS: SETLE CATEGORY: SETCC EXTENSION: BASE IFORM: SETLE_GPR8 ISA_SET: I386 SHORT: setle bpl */ ASSERT_EQ(4, ild(u"@☼€┼")); } TEST(x86ild, test_400F94C7) { /* ICLASS: SETZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETZ_GPR8 ISA_SET: I386 SHORT: setz dil */ ASSERT_EQ(4, ild(u"@☼ö╟")); } TEST(x86ild, test_400F94C6) { /* ICLASS: SETZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETZ_GPR8 ISA_SET: I386 SHORT: setz sil */ ASSERT_EQ(4, ild(u"@☼ö╞")); } TEST(x86ild, test_0FBFF8) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_GPR16 ISA_SET: I386 SHORT: movsx edi, ax */ ASSERT_EQ(3, ild(u"☼┐°")); } TEST(x86ild, test_0FBFC7) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_GPR16 ISA_SET: I386 SHORT: movsx eax, di */ ASSERT_EQ(3, ild(u"☼┐╟")); } TEST(x86ild, test_0FBEF8) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_GPR8 ISA_SET: I386 SHORT: movsx edi, al */ ASSERT_EQ(3, ild(u"☼╛°")); } TEST(x86ild, test_0FBE4A00) { /* ICLASS: MOVSX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVSX_GPRv_MEMb ISA_SET: I386 SHORT: movsx ecx, byte ptr [rdx] */ ASSERT_EQ(4, ild(u"☼╛J ")); } TEST(x86ild, test_0FB7FA) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR16 ISA_SET: I386 SHORT: movzx edi, dx */ ASSERT_EQ(3, ild(u"☼╖·")); } TEST(x86ild, test_0FB7D2) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR16 ISA_SET: I386 SHORT: movzx edx, dx */ ASSERT_EQ(3, ild(u"☼╖╥")); } TEST(x86ild, test_0FB7742400) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx esi, word ptr [rsp] */ ASSERT_EQ(5, ild(u"☼╖t$ ")); } TEST(x86ild, test_0FB75000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx edx, word ptr [rax] */ ASSERT_EQ(4, ild(u"☼╖P ")); } TEST(x86ild, test_0FB74600) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx eax, word ptr [rsi] */ ASSERT_EQ(4, ild(u"☼╖F ")); } TEST(x86ild, test_0FB74200) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx eax, word ptr [rdx] */ ASSERT_EQ(4, ild(u"☼╖B ")); } TEST(x86ild, test_0FB739) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx edi, word ptr [rcx] */ ASSERT_EQ(3, ild(u"☼╖9")); } TEST(x86ild, test_0FB700) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMw ISA_SET: I386 SHORT: movzx eax, word ptr [rax] */ ASSERT_EQ(3, ild(u"☼╖ ")); } TEST(x86ild, test_0FB6F9) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx edi, cl */ ASSERT_EQ(3, ild(u"☼╢∙")); } TEST(x86ild, test_0FB6F2) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx esi, dl */ ASSERT_EQ(3, ild(u"☼╢≥")); } TEST(x86ild, test_0FB6F1) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx esi, cl */ ASSERT_EQ(3, ild(u"☼╢±")); } TEST(x86ild, test_0FB6F0) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_GPR8 ISA_SET: I386 SHORT: movzx esi, al */ ASSERT_EQ(3, ild(u"☼╢≡")); } TEST(x86ild, test_0FB69C2400000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ebx, byte ptr [rsp] */ ASSERT_EQ(8, ild(u"☼╢£$    ")); } TEST(x86ild, test_0FB6941100000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edx, byte ptr [rcx+rdx*1] */ ASSERT_EQ(8, ild(u"☼╢ö◄    ")); } TEST(x86ild, test_0FB68C1000000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ecx, byte ptr [rax+rdx*1] */ ASSERT_EQ(8, ild(u"☼╢î►    ")); } TEST(x86ild, test_0FB67B00) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edi, byte ptr [rbx] */ ASSERT_EQ(4, ild(u"☼╢{ ")); } TEST(x86ild, test_0FB65F00) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ebx, byte ptr [rdi] */ ASSERT_EQ(4, ild(u"☼╢_ ")); } TEST(x86ild, test_0FB65800) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ebx, byte ptr [rax] */ ASSERT_EQ(4, ild(u"☼╢X ")); } TEST(x86ild, test_0FB65200) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edx, byte ptr [rdx] */ ASSERT_EQ(4, ild(u"☼╢R ")); } TEST(x86ild, test_0FB65000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edx, byte ptr [rax] */ ASSERT_EQ(4, ild(u"☼╢P ")); } TEST(x86ild, test_0FB64600) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rsi] */ ASSERT_EQ(4, ild(u"☼╢F ")); } TEST(x86ild, test_0FB6443700) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rdi+rsi*1] */ ASSERT_EQ(5, ild(u"☼╢D7 ")); } TEST(x86ild, test_0FB63F) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edi, byte ptr [rdi] */ ASSERT_EQ(3, ild(u"☼╢⁇")); } TEST(x86ild, test_0FB63C08) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edi, byte ptr [rax+rcx*1] */ ASSERT_EQ(4, ild(u"☼╢<◘")); } TEST(x86ild, test_0FB63430) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx esi, byte ptr [rax+rsi*1] */ ASSERT_EQ(4, ild(u"☼╢40")); } TEST(x86ild, test_0FB610) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx edx, byte ptr [rax] */ ASSERT_EQ(3, ild(u"☼╢►")); } TEST(x86ild, test_0FB60F) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ecx, byte ptr [rdi] */ ASSERT_EQ(3, ild(u"☼╢☼")); } TEST(x86ild, test_0FB60CD500000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ecx, byte ptr [rdx*8] */ ASSERT_EQ(8, ild(u"☼╢♀╒    ")); } TEST(x86ild, test_0FB60C08) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ecx, byte ptr [rax+rcx*1] */ ASSERT_EQ(4, ild(u"☼╢♀◘")); } TEST(x86ild, test_0FB608) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx ecx, byte ptr [rax] */ ASSERT_EQ(3, ild(u"☼╢◘")); } TEST(x86ild, test_0FB607) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rdi] */ ASSERT_EQ(3, ild(u"☼╢•")); } TEST(x86ild, test_0FB6049500000000) { /* ICLASS: MOVZX CATEGORY: DATAXFER EXTENSION: BASE IFORM: MOVZX_GPRv_MEMb ISA_SET: I386 SHORT: movzx eax, byte ptr [rdx*4] */ ASSERT_EQ(8, ild(u"☼╢♦ò    ")); } TEST(x86ild, test_0FA3D0) { /* ICLASS: BT CATEGORY: BITBYTE EXTENSION: BASE IFORM: BT_GPRv_GPRv ISA_SET: I386 SHORT: bt eax, edx */ ASSERT_EQ(3, ild(u"☼ú╨")); } TEST(x86ild, test_0F9CC1) { /* ICLASS: SETL CATEGORY: SETCC EXTENSION: BASE IFORM: SETL_GPR8 ISA_SET: I386 SHORT: setl cl */ ASSERT_EQ(3, ild(u"☼£┴")); } TEST(x86ild, test_0F97C1) { /* ICLASS: SETNBE CATEGORY: SETCC EXTENSION: BASE IFORM: SETNBE_GPR8 ISA_SET: I386 SHORT: setnbe cl */ ASSERT_EQ(3, ild(u"☼ù┴")); } TEST(x86ild, test_0F96C2) { /* ICLASS: SETBE CATEGORY: SETCC EXTENSION: BASE IFORM: SETBE_GPR8 ISA_SET: I386 SHORT: setbe dl */ ASSERT_EQ(3, ild(u"☼û┬")); } TEST(x86ild, test_0F95C1) { /* ICLASS: SETNZ CATEGORY: SETCC EXTENSION: BASE IFORM: SETNZ_GPR8 ISA_SET: I386 SHORT: setnz cl */ ASSERT_EQ(3, ild(u"☼ò┴")); }
33,327
1,754
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_widenop_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" /** * @fileoverview Hefty NOPs. */ TEST(x86ild, test_nop9_660F1F840000000000) { /* ICLASS: NOP CATEGORY: WIDENOP EXTENSION: BASE IFORM: NOP_MEMv_GPRv_0F1F ISA_SET: FAT_NOP SHORT: nop word ptr [rax+rax*1], ax */ ASSERT_EQ(9, ild(u"f☼▼ä     ")); } TEST(x86ild, test_nop8_0F1F840000000000) { /* nopl 0x00000000(%rax,%rax,1) */ ASSERT_EQ(8, ild(u"☼▼ä     ")); } TEST(x86ild, test_nop7_0F1F8000000000) { /* nopl 0x00000000(%rax) */ ASSERT_EQ(7, ild(u"☼▼Ç    ")); } TEST(x86ild, test_nop6_660F1F440000) { /* ICLASS: NOP CATEGORY: WIDENOP EXTENSION: BASE IFORM: NOP_MEMv_GPRv_0F1F ISA_SET: FAT_NOP SHORT: nop word ptr [rax+rax*1], ax */ ASSERT_EQ(6, ild(u"f☼▼D  ")); } TEST(x86ild, test_nop5_0F1F440000) { /* ICLASS: NOP CATEGORY: WIDENOP EXTENSION: BASE IFORM: NOP_MEMv_GPRv_0F1F ISA_SET: FAT_NOP SHORT: nop dword ptr [rax+rax*1], eax */ ASSERT_EQ(5, ild(u"☼▼D  ")); } TEST(x86ild, test_nop4_0F1F4000) { /* ICLASS: NOP CATEGORY: WIDENOP EXTENSION: BASE IFORM: NOP_MEMv_GPRv_0F1F ISA_SET: FAT_NOP SHORT: nop dword ptr [rax], eax */ ASSERT_EQ(4, ild(u"☼▼@ ")); } TEST(x86ild, test_nop3_0F1F00) { /* ICLASS: NOP CATEGORY: WIDENOP EXTENSION: BASE IFORM: NOP_MEMv_GPRv_0F1F ISA_SET: FAT_NOP SHORT: nop dword ptr [rax], eax */ ASSERT_EQ(3, ild(u"☼▼ ")); } TEST(x86ild, test_nop2_6690) { /* xchg %ax,%ax */ ASSERT_EQ(2, ild(u"fÉ")); } TEST(x86ild, test_nop1_90) { /* xchg %eax,%eax */ ASSERT_EQ(1, ild(u"É")); }
3,564
106
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/x86ild_popular_i186_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" #include "test/libc/xed/lib.h" #include "third_party/xed/x86.h" TEST(x86ild, test_C0E800) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr al, 0x0 */ ASSERT_EQ(3, ild(u"└Φ ")); } TEST(x86ild, test_C1EE00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr esi, 0x0 */ ASSERT_EQ(3, ild(u"┴ε ")); } TEST(x86ild, test_48C1E000) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl rax, 0x0 */ ASSERT_EQ(4, ild(u"H┴α ")); } TEST(x86ild, test_66C1EE00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr si, 0x0 */ ASSERT_EQ(4, ild(u"f┴ε ")); } TEST(x86ild, test_486BC000) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv_IMMb ISA_SET: I186 SHORT: imul rax, rax, 0x0 */ ASSERT_EQ(4, ild(u"Hk└ ")); } TEST(x86ild, test_C1E000) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl eax, 0x0 */ ASSERT_EQ(3, ild(u"┴α ")); } TEST(x86ild, test_486BED00) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv_IMMb ISA_SET: I186 SHORT: imul rbp, rbp, 0x0 */ ASSERT_EQ(4, ild(u"Hkφ ")); } TEST(x86ild, test_69D000000000) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv_IMMz ISA_SET: I186 SHORT: imul edx, eax, 0x0 */ ASSERT_EQ(6, ild(u"i╨    ")); } TEST(x86ild, test_48C1EA00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr rdx, 0x0 */ ASSERT_EQ(4, ild(u"H┴Ω ")); } TEST(x86ild, test_C0EA00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr dl, 0x0 */ ASSERT_EQ(3, ild(u"└Ω ")); } TEST(x86ild, test_C1E200) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl edx, 0x0 */ ASSERT_EQ(3, ild(u"┴Γ ")); } TEST(x86ild, test_C1E600) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl esi, 0x0 */ ASSERT_EQ(3, ild(u"┴μ ")); } TEST(x86ild, test_66C1EA00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr dx, 0x0 */ ASSERT_EQ(4, ild(u"f┴Ω ")); } TEST(x86ild, test_486BD200) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv_IMMb ISA_SET: I186 SHORT: imul rdx, rdx, 0x0 */ ASSERT_EQ(4, ild(u"Hk╥ ")); } TEST(x86ild, test_C0EA83) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr dl, 0x83 */ ASSERT_EQ(3, ild(u"└Ωâ")); } TEST(x86ild, test_C1E800) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr eax, 0x0 */ ASSERT_EQ(3, ild(u"┴Φ ")); } TEST(x86ild, test_C1EA00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr edx, 0x0 */ ASSERT_EQ(3, ild(u"┴Ω ")); } TEST(x86ild, test_48C1E500) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl rbp, 0x0 */ ASSERT_EQ(4, ild(u"H┴σ ")); } TEST(x86ild, test_66C1E800) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr ax, 0x0 */ ASSERT_EQ(4, ild(u"f┴Φ ")); } TEST(x86ild, test_C1E700) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl edi, 0x0 */ ASSERT_EQ(3, ild(u"┴τ ")); } TEST(x86ild, test_C0E900) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr cl, 0x0 */ ASSERT_EQ(3, ild(u"└Θ ")); } TEST(x86ild, test_C1E100) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl ecx, 0x0 */ ASSERT_EQ(3, ild(u"┴ß ")); } TEST(x86ild, test_48C1E200) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl rdx, 0x0 */ ASSERT_EQ(4, ild(u"H┴Γ ")); } TEST(x86ild, test_40C0EE00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr sil, 0x0 */ ASSERT_EQ(4, ild(u"@└ε ")); } TEST(x86ild, test_69C000000000) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv_IMMz ISA_SET: I186 SHORT: imul eax, eax, 0x0 */ ASSERT_EQ(6, ild(u"i└    ")); } TEST(x86ild, test_48C1E800) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr rax, 0x0 */ ASSERT_EQ(4, ild(u"H┴Φ ")); } TEST(x86ild, test_C0E883) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr al, 0x83 */ ASSERT_EQ(3, ild(u"└Φâ")); } TEST(x86ild, test_48C1E100) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl rcx, 0x0 */ ASSERT_EQ(4, ild(u"H┴ß ")); } TEST(x86ild, test_4869C000000000) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv_IMMz ISA_SET: I186 SHORT: imul rax, rax, 0x0 */ ASSERT_EQ(7, ild(u"Hi└    ")); } TEST(x86ild, test_48C1E700) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl rdi, 0x0 */ ASSERT_EQ(4, ild(u"H┴τ ")); } TEST(x86ild, test_41C0E800) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr r8b, 0x0 */ ASSERT_EQ(4, ild(u"A└Φ ")); } TEST(x86ild, test_C0E8C0) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr al, 0xc0 */ ASSERT_EQ(3, ild(u"└Φ└")); } TEST(x86ild, test_C0EA66) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr dl, 0x66 */ ASSERT_EQ(3, ild(u"└Ωf")); } TEST(x86ild, test_48C1E600) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl rsi, 0x0 */ ASSERT_EQ(4, ild(u"H┴μ ")); } TEST(x86ild, test_C0E848) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr al, 0x48 */ ASSERT_EQ(3, ild(u"└ΦH")); } TEST(x86ild, test_4869D200000000) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv_IMMz ISA_SET: I186 SHORT: imul rdx, rdx, 0x0 */ ASSERT_EQ(7, ild(u"Hi╥    ")); } TEST(x86ild, test_C1E900) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr ecx, 0x0 */ ASSERT_EQ(3, ild(u"┴Θ ")); } TEST(x86ild, test_40C0ED00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr bpl, 0x0 */ ASSERT_EQ(4, ild(u"@└φ ")); } TEST(x86ild, test_C1EF00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr edi, 0x0 */ ASSERT_EQ(3, ild(u"┴∩ ")); } TEST(x86ild, test_66C1EF00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr di, 0x0 */ ASSERT_EQ(4, ild(u"f┴∩ ")); } TEST(x86ild, test_486BCA00) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv_IMMb ISA_SET: I186 SHORT: imul rcx, rdx, 0x0 */ ASSERT_EQ(4, ild(u"Hk╩ ")); } TEST(x86ild, test_41C1EA00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr r10d, 0x0 */ ASSERT_EQ(4, ild(u"A┴Ω ")); } TEST(x86ild, test_41C1E000) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl r8d, 0x0 */ ASSERT_EQ(4, ild(u"A┴α ")); } TEST(x86ild, test_40C0EF00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr dil, 0x0 */ ASSERT_EQ(4, ild(u"@└∩ ")); } TEST(x86ild, test_49C1E000) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl r8, 0x0 */ ASSERT_EQ(4, ild(u"I┴α ")); } TEST(x86ild, test_41C1E800) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr r8d, 0x0 */ ASSERT_EQ(4, ild(u"A┴Φ ")); } TEST(x86ild, test_41C1E200) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl r10d, 0x0 */ ASSERT_EQ(4, ild(u"A┴Γ ")); } TEST(x86ild, test_41C0E900) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr r9b, 0x0 */ ASSERT_EQ(4, ild(u"A└Θ ")); } TEST(x86ild, test_C0EAC0) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPR8_IMMb ISA_SET: I186 SHORT: shr dl, 0xc0 */ ASSERT_EQ(3, ild(u"└Ω└")); } TEST(x86ild, test_66C1E900) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr cx, 0x0 */ ASSERT_EQ(4, ild(u"f┴Θ ")); } TEST(x86ild, test_48C1F800) { /* ICLASS: SAR CATEGORY: SHIFT EXTENSION: BASE IFORM: SAR_GPRv_IMMb ISA_SET: I186 SHORT: sar rax, 0x0 */ ASSERT_EQ(4, ild(u"H┴° ")); } TEST(x86ild, test_41C1EB00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr r11d, 0x0 */ ASSERT_EQ(4, ild(u"A┴δ ")); } TEST(x86ild, test_41C1E300) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl r11d, 0x0 */ ASSERT_EQ(4, ild(u"A┴π ")); } TEST(x86ild, test_C1ED00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr ebp, 0x0 */ ASSERT_EQ(3, ild(u"┴φ ")); } TEST(x86ild, test_C1EB00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr ebx, 0x0 */ ASSERT_EQ(3, ild(u"┴δ ")); } TEST(x86ild, test_C1E500) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl ebp, 0x0 */ ASSERT_EQ(3, ild(u"┴σ ")); } TEST(x86ild, test_69D800000000) { /* ICLASS: IMUL CATEGORY: BINARY EXTENSION: BASE IFORM: IMUL_GPRv_GPRv_IMMz ISA_SET: I186 SHORT: imul ebx, eax, 0x0 */ ASSERT_EQ(6, ild(u"i╪    ")); } TEST(x86ild, test_6641C1EE00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr r14w, 0x0 */ ASSERT_EQ(5, ild(u"fA┴ε ")); } TEST(x86ild, test_6641C1ED00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr r13w, 0x0 */ ASSERT_EQ(5, ild(u"fA┴φ ")); } TEST(x86ild, test_6641C1E800) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr r8w, 0x0 */ ASSERT_EQ(5, ild(u"fA┴Φ ")); } TEST(x86ild, test_49C1E100) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl r9, 0x0 */ ASSERT_EQ(4, ild(u"I┴ß ")); } TEST(x86ild, test_48C1FE74) { /* ICLASS: SAR CATEGORY: SHIFT EXTENSION: BASE IFORM: SAR_GPRv_IMMb ISA_SET: I186 SHORT: sar rsi, 0x74 */ ASSERT_EQ(4, ild(u"H┴■t")); } TEST(x86ild, test_48C1FE00) { /* ICLASS: SAR CATEGORY: SHIFT EXTENSION: BASE IFORM: SAR_GPRv_IMMb ISA_SET: I186 SHORT: sar rsi, 0x0 */ ASSERT_EQ(4, ild(u"H┴■ ")); } TEST(x86ild, test_48C1FB00) { /* ICLASS: SAR CATEGORY: SHIFT EXTENSION: BASE IFORM: SAR_GPRv_IMMb ISA_SET: I186 SHORT: sar rbx, 0x0 */ ASSERT_EQ(4, ild(u"H┴√ ")); } TEST(x86ild, test_41C1EE00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr r14d, 0x0 */ ASSERT_EQ(4, ild(u"A┴ε ")); } TEST(x86ild, test_41C1EC00) { /* ICLASS: SHR CATEGORY: SHIFT EXTENSION: BASE IFORM: SHR_GPRv_IMMb ISA_SET: I186 SHORT: shr r12d, 0x0 */ ASSERT_EQ(4, ild(u"A┴∞ ")); } TEST(x86ild, test_41C1E700) { /* ICLASS: SHL CATEGORY: SHIFT EXTENSION: BASE IFORM: SHL_GPRv_IMMb_C1r4 ISA_SET: I186 SHORT: shl r15d, 0x0 */ ASSERT_EQ(4, ild(u"A┴τ ")); }
15,540
826
jart/cosmopolitan
false
cosmopolitan/test/libc/xed/test.mk
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ #───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ TEST_LIBC_XED_FILES := $(wildcard test/libc/xed/*) TEST_LIBC_XED_HDRS = $(filter %.h,$(TEST_LIBC_XED_FILES)) #─────────────────────────────────────────────────────────────────────────────── PKGS += TEST_LIBC_XED_TESTLIB TEST_LIBC_XED_TESTLIB_SRCS = \ $(TEST_LIBC_XED_TESTLIB_A_SRCS) TEST_LIBC_XED_TESTLIB_OBJS = \ $(TEST_LIBC_XED_TESTLIB_A_OBJS) TEST_LIBC_XED_TESTLIB = \ $(TEST_LIBC_XED_TESTLIB_A_DEPS) \ $(TEST_LIBC_XED_TESTLIB_A) TEST_LIBC_XED_TESTLIB_A = o/$(MODE)/test/libc/xed/testlib.a TEST_LIBC_XED_TESTLIB_A_SRCS = $(filter %_lib.c,$(TEST_LIBC_XED_FILES)) TEST_LIBC_XED_TESTLIB_A_OBJS = \ $(TEST_LIBC_XED_TESTLIB_A_SRCS:%.c=o/$(MODE)/%.o) TEST_LIBC_XED_TESTLIB_A_DIRECTDEPS = \ LIBC_INTRIN \ LIBC_STR \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ LIBC_STUBS \ LIBC_TESTLIB \ LIBC_X \ THIRD_PARTY_XED TEST_LIBC_XED_TESTLIB_A_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_XED_TESTLIB_A_DIRECTDEPS),$($(x)))) $(TEST_LIBC_XED_TESTLIB_A).pkg: \ $(TEST_LIBC_XED_TESTLIB_A_OBJS) \ $(foreach x,$(TEST_LIBC_XED_TESTLIB_A_DIRECTDEPS),$($(x)_A).pkg) $(TEST_LIBC_XED_TESTLIB_A): \ test/libc/xed/ \ $(TEST_LIBC_XED_TESTLIB_A).pkg \ $(TEST_LIBC_XED_TESTLIB_A_OBJS) #─────────────────────────────────────────────────────────────────────────────── PKGS += TEST_LIBC_XED TEST_LIBC_XED_SRCS = $(filter %_test.c,$(TEST_LIBC_XED_FILES)) TEST_LIBC_XED_OBJS = \ $(TEST_LIBC_XED_SRCS:%.c=o/$(MODE)/%.o) TEST_LIBC_XED_COMS = \ $(TEST_LIBC_XED_SRCS:%.c=o/$(MODE)/%.com) TEST_LIBC_XED_BINS = \ $(TEST_LIBC_XED_COMS) \ $(TEST_LIBC_XED_COMS:%=%.dbg) TEST_LIBC_XED_TESTS = \ $(TEST_LIBC_XED_SRCS:%.c=o/$(MODE)/%.com.ok) TEST_LIBC_XED_CHECKS = \ $(TEST_LIBC_XED_SRCS:%.c=o/$(MODE)/%.com.runs) TEST_LIBC_XED_DIRECTDEPS = \ LIBC_INTRIN \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ LIBC_RUNTIME \ LIBC_STUBS \ LIBC_TESTLIB \ TEST_LIBC_XED_TESTLIB \ THIRD_PARTY_XED TEST_LIBC_XED_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_XED_DIRECTDEPS),$($(x)))) o/$(MODE)/test/libc/xed/xed.pkg: \ $(TEST_LIBC_XED_OBJS) \ $(foreach x,$(TEST_LIBC_XED_DIRECTDEPS),$($(x)_A).pkg) o/$(MODE)/test/libc/xed/%.com.dbg: \ $(TEST_LIBC_XED_DEPS) \ o/$(MODE)/test/libc/xed/%.o \ o/$(MODE)/test/libc/xed/xed.pkg \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) #─────────────────────────────────────────────────────────────────────────────── .PHONY: o/$(MODE)/test/libc/xed o/$(MODE)/test/libc/xed: \ $(TEST_LIBC_XED_BINS) \ $(TEST_LIBC_XED_CHECKS)
3,369
105
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/resolvehostsreverse_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/hoststxt.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/testlib/testlib.h" TEST(ParseHostsTxt, testNotFound) { const char kInput[] = "# this is a comment\n" "# IP HOST1 HOST2\n" "203.0.113.1 lol.example lol\n" "203.0.113.2 cat.example cat\n"; char name[256]; uint8_t ip[4] = {127, 0, 113, 1}; struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt)); FILE *f = fmemopen(NULL, BUFSIZ, "r+"); ASSERT_EQ(1, fwrite(kInput, strlen(kInput), 1, f)); rewind(f); ASSERT_EQ(0, ParseHostsTxt(ht, f)); ASSERT_EQ(4, ht->entries.i); ASSERT_EQ(0, ResolveHostsReverse(ht, AF_INET, ip, name, sizeof(name))); FreeHostsTxt(&ht); fclose(f); } TEST(ParseHostsTxt, testFirstLookup) { const char kInput[] = "# this is a comment\n" "# IP HOST1 HOST2\n" "203.0.113.1 lol.example lol\n" "203.0.113.2 cat.example cat\n"; char name[256]; uint8_t ip[4] = {203, 0, 113, 1}; struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt)); FILE *f = fmemopen(NULL, BUFSIZ, "r+"); ASSERT_EQ(1, fwrite(kInput, strlen(kInput), 1, f)); rewind(f); ASSERT_EQ(0, ParseHostsTxt(ht, f)); ASSERT_EQ(4, ht->entries.i); ASSERT_EQ(1, ResolveHostsReverse(ht, AF_INET, ip, name, sizeof(name))); EXPECT_STREQ("lol.example", name); FreeHostsTxt(&ht); fclose(f); } TEST(ParseHostsTxt, testSecondLookup) { const char kInput[] = "# this is a comment\n" "# IP HOST1 HOST2\n" "203.0.113.1 lol.example lol\n" "203.0.113.2 cat.example cat\n"; char name[256]; uint8_t ip[4] = {203, 0, 113, 2}; struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt)); FILE *f = fmemopen(NULL, BUFSIZ, "r+"); ASSERT_EQ(1, fwrite(kInput, strlen(kInput), 1, f)); rewind(f); ASSERT_EQ(0, ParseHostsTxt(ht, f)); ASSERT_EQ(4, ht->entries.i); ASSERT_EQ(1, ResolveHostsReverse(ht, AF_INET, ip, name, sizeof(name))); EXPECT_STREQ("cat.example", name); FreeHostsTxt(&ht); fclose(f); }
4,059
80
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/resolvehoststxt_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/dns.h" #include "libc/dns/hoststxt.h" #include "libc/mem/mem.h" #include "libc/sock/sock.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/testlib/testlib.h" static const char *EzIp4Lookup(const struct HostsTxt *ht, const char *name) { struct sockaddr_in addr4; if (ResolveHostsTxt(ht, AF_INET, name, (void *)&addr4, sizeof(struct sockaddr_in), NULL) > 0) { static char g_ipbuf[16]; return inet_ntop(AF_INET, &addr4.sin_addr, g_ipbuf, sizeof(g_ipbuf)); } else { return NULL; } } static const char *EzCanonicalize(const struct HostsTxt *ht, const char *name) { const char *res; return ResolveHostsTxt(ht, AF_INET, name, NULL, 0, &res) > 0 ? res : NULL; } static const char kInput[] = "127.0.0.1 localhost\n" "203.0.113.1 lol.example. lol\n" "203.0.113.2 cat.example. cat\n"; TEST(ResolveHostsTxt, testBasicLookups) { struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt)); FILE *f = fmemopen(kInput, strlen(kInput), "r+"); ASSERT_EQ(0, ParseHostsTxt(ht, f)); ASSERT_EQ(5, ht->entries.i); EXPECT_STREQ("127.0.0.1", EzIp4Lookup(ht, "localhost")); EXPECT_STREQ("203.0.113.1", EzIp4Lookup(ht, "lol")); EXPECT_STREQ("203.0.113.1", EzIp4Lookup(ht, "lol.example")); EXPECT_STREQ("203.0.113.1", EzIp4Lookup(ht, "lol.example.")); EXPECT_STREQ("203.0.113.2", EzIp4Lookup(ht, "cat")); EXPECT_STREQ("203.0.113.2", EzIp4Lookup(ht, "cat.example.")); EXPECT_EQ(NULL, EzIp4Lookup(ht, "boop")); FreeHostsTxt(&ht); fclose(f); } TEST(ResolveHostsTxt, testCanonicalize) { struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt)); FILE *f = fmemopen(kInput, strlen(kInput), "r+"); ASSERT_EQ(0, ParseHostsTxt(ht, f)); ASSERT_EQ(5, ht->entries.i); EXPECT_STREQ("localhost", EzCanonicalize(ht, "localhost")); EXPECT_STREQ("lol.example.", EzCanonicalize(ht, "lol")); EXPECT_STREQ("lol.example.", EzCanonicalize(ht, "lol.example")); EXPECT_STREQ("lol.example.", EzCanonicalize(ht, "lol.example.")); EXPECT_STREQ("cat.example.", EzCanonicalize(ht, "cat")); EXPECT_STREQ("cat.example.", EzCanonicalize(ht, "cat.example.")); EXPECT_EQ(NULL, EzCanonicalize(ht, "boop")); FreeHostsTxt(&ht); fclose(f); }
4,155
79
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/servicestxt_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ This is free and unencumbered software released into the public domain. │ │ │ │ Anyone is free to copy, modify, publish, use, compile, sell, or │ │ distribute this software, either in source code form or as a compiled │ │ binary, for any purpose, commercial or non-commercial, and by any │ │ means. │ │ │ │ In jurisdictions that recognize copyright laws, the author or authors │ │ of this software dedicate any and all copyright interest in the │ │ software to the public domain. We make this dedication for the benefit │ │ of the public at large and to the detriment of our heirs and │ │ successors. We intend this dedication to be an overt act of │ │ relinquishment in perpetuity of all present and future rights to this │ │ software under copyright law. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │ │ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │ │ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │ │ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR │ │ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │ │ OTHER DEALINGS IN THE SOFTWARE. │ │ │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/dns/dns.h" #include "libc/dns/ent.h" #include "libc/dns/servicestxt.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" char testlib_enable_tmp_setup_teardown; void SetUp() { int fd; const char* sample = "\ # skip comment string\n\ chargen 19/tcp ttytst source\n\ chargen 19/udp ttytst source\n\ ssh 22/tcp # SSH Remote Login Protocol"; ASSERT_NE(-1, (fd = creat("services", 0755))); ASSERT_NE(-1, write(fd, sample, strlen(sample))); ASSERT_NE(-1, close(fd)); } TEST(LookupServicesByPort, GetNameWhenPortCorrect) { char name[8]; /* service names are of length 3 */ char eitherproto[8]; /* protocol names are of length 3 */ char proto1[] = "tcp"; char proto2[] = "udp"; char* localproto; strcpy(eitherproto, ""); strcpy(name, ""); localproto = eitherproto; ASSERT_EQ(-1, /* non existent port */ LookupServicesByPort(965, localproto, sizeof(eitherproto), name, sizeof(name), "services")); ASSERT_EQ('\0', localproto[0]); localproto = eitherproto; ASSERT_EQ(-1, /* port in network byte order */ LookupServicesByPort(htons(22), localproto, sizeof(eitherproto), name, sizeof(name), "services")); ASSERT_EQ('\0', localproto[0]); localproto = proto2; ASSERT_EQ(-1, /* port ok but wrong protocol */ LookupServicesByPort(22, localproto, sizeof(proto2), name, sizeof(name), "services")); ASSERT_STREQ(proto2, "udp"); localproto = proto1; ASSERT_EQ( -1, /* protocol is non-NULL/length must be nonzero */ LookupServicesByPort(22, localproto, 0, name, sizeof(name), "services")); ASSERT_STREQ(proto1, "tcp"); localproto = proto1; ASSERT_EQ(-1, /* sizeof(name) insufficient, memccpy failure */ LookupServicesByPort(22, localproto, sizeof(proto1), name, 1, "services")); ASSERT_STREQ(proto1, "tcp"); ASSERT_STREQ(name, ""); /* cleaned up after memccpy failed */ localproto = eitherproto; ASSERT_EQ( -1, /* sizeof(proto) insufficient, memccpy failure */ LookupServicesByPort(22, localproto, 1, name, sizeof(name), "services")); ASSERT_STREQ(eitherproto, ""); /* cleaned up after memccpy failed */ localproto = proto1; ASSERT_EQ(0, LookupServicesByPort(22, localproto, sizeof(proto1), name, sizeof(name), "services")); ASSERT_STREQ(name, "ssh"); ASSERT_STREQ(proto1, "tcp"); localproto = proto2; ASSERT_EQ(0, LookupServicesByPort(19, localproto, sizeof(proto2), name, sizeof(name), "services")); ASSERT_STREQ(name, "chargen"); ASSERT_STREQ(proto2, "udp"); localproto = eitherproto; ASSERT_EQ(0, /* pick first matching protocol */ LookupServicesByPort(19, localproto, sizeof(eitherproto), name, sizeof(name), "services")); ASSERT_STREQ(name, "chargen"); ASSERT_NE('\0', localproto[0]); /* buffer filled during the call */ ASSERT_STREQ(eitherproto, "tcp"); } TEST(LookupServicesByName, GetPortWhenNameOrAlias) { char name[8]; /* service names are of length 3 */ char eitherproto[8]; /* protocol names are of length 3 */ char proto1[] = "tcp"; char proto2[] = "udp"; char* localproto; strcpy(eitherproto, ""); strcpy(name, ""); localproto = eitherproto; ASSERT_EQ(-1, /* non-existent name */ LookupServicesByName("http", localproto, sizeof(eitherproto), name, sizeof(name), "services")); ASSERT_EQ('\0', localproto[0]); localproto = proto2; ASSERT_EQ(-1, /* name exists but wrong protocol */ LookupServicesByName("ssh", localproto, sizeof(proto2), name, sizeof(name), "services")); ASSERT_STREQ(proto2, "udp"); localproto = proto2; ASSERT_EQ(-1, /* protocol is non-NULL/length must be nonzero */ LookupServicesByName("ssh", localproto, 0, name, sizeof(name), "services")); ASSERT_STREQ(proto2, "udp"); localproto = proto1; ASSERT_EQ(-1, /* sizeof(name) insufficient, memccpy failure */ LookupServicesByName("ssh", localproto, sizeof(proto1), name, 1, "services")); ASSERT_STREQ(proto1, "tcp"); ASSERT_STREQ(name, ""); /* cleaned up after memccpy failed */ localproto = eitherproto; ASSERT_EQ(-1, /* sizeof(proto) insufficient, memccpy failure */ LookupServicesByName("ssh", localproto, 1, name, sizeof(name), "services")); ASSERT_STREQ(eitherproto, ""); /* cleaned up after memccpy failed */ localproto = proto1; ASSERT_EQ(22, LookupServicesByName("ssh", localproto, sizeof(proto1), name, sizeof(name), "services")); ASSERT_STREQ(name, "ssh"); /* official name written to buffer */ ASSERT_STREQ(proto1, "tcp"); localproto = proto2; ASSERT_EQ(19, /* works if alias provided */ LookupServicesByName("ttytst", localproto, sizeof(proto2), name, sizeof(name), "services")); ASSERT_STREQ(name, "chargen"); /* official name written to buffer */ localproto = proto2; ASSERT_EQ(19, /* can get port returned without official name */ LookupServicesByName("ttytst", localproto, sizeof(proto2), NULL, 0, "services")); localproto = eitherproto; ASSERT_EQ(19, /* pick first matching protocol */ LookupServicesByName("source", localproto, sizeof(eitherproto), name, sizeof(name), "services")); ASSERT_STREQ(name, "chargen"); ASSERT_STREQ(localproto, "tcp"); }
8,406
181
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/comparednsnames_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/dns/dns.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" void SetUpOnce(void) { ASSERT_SYS(0, 0, pledge("stdio rpath", 0)); } TEST(CompareDnsNames, testEmpty) { char *A = strcpy(malloc(1), ""); char *B = strcpy(malloc(1), ""); EXPECT_EQ(CompareDnsNames(A, B), 0); EXPECT_EQ(CompareDnsNames(A, A), 0); free(B); free(A); } TEST(CompareDnsNames, testDotless_caseInsensitiveBehavior) { char *A = malloc(2); char *B = malloc(2); EXPECT_EQ(CompareDnsNames(strcpy(A, "a"), strcpy(B, "a")), 0); EXPECT_EQ(CompareDnsNames(A, A), 0); EXPECT_EQ(CompareDnsNames(strcpy(A, "a"), strcpy(B, "A")), 0); EXPECT_EQ(CompareDnsNames(strcpy(A, "A"), strcpy(B, "a")), 0); EXPECT_LT(CompareDnsNames(strcpy(A, "a"), strcpy(B, "b")), 0); EXPECT_LT(CompareDnsNames(strcpy(A, "a"), strcpy(B, "B")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "d"), strcpy(B, "a")), 0); free(B); free(A); } TEST(CompareDnsNames, testMultiLabel_lexiReverse) { char *A = malloc(16); char *B = malloc(16); EXPECT_EQ(CompareDnsNames(strcpy(A, "a.example"), strcpy(B, "a.example")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "b.example"), strcpy(B, "a.example")), 0); EXPECT_LT(CompareDnsNames(strcpy(A, "b.example"), strcpy(B, "a.examplz")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "a.zxample"), strcpy(B, "a.examplz")), 0); EXPECT_EQ(CompareDnsNames(strcpy(A, "c.a.example"), strcpy(B, "c.a.example")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "d.a.example"), strcpy(B, "c.a.example")), 0); EXPECT_LT(CompareDnsNames(strcpy(A, "cat.example"), strcpy(B, "lol.example")), 0); free(B); free(A); } TEST(CompareDnsNames, testTldDotQualifier_canBeEqualToDottedNames) { char *A = malloc(16); char *B = malloc(16); EXPECT_EQ( CompareDnsNames(strcpy(B, "aaa.example."), strcpy(A, "aaa.example")), 0); free(B); free(A); } TEST(CompareDnsNames, testFullyQualified_alwaysComesFirst) { char *A = malloc(16); char *B = malloc(16); EXPECT_LT(CompareDnsNames(strcpy(B, "aaa.example."), strcpy(A, "zzz")), 0); EXPECT_LT(CompareDnsNames(strcpy(B, "zzz.example."), strcpy(A, "aaa")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "zzz"), strcpy(B, "aaa.example.")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "aaa"), strcpy(B, "zzz.example.")), 0); free(B); free(A); } TEST(CompareDnsNames, testLikelySld_alwaysComesBeforeLocalName) { char *A = malloc(16); char *B = malloc(16); EXPECT_LT(CompareDnsNames(strcpy(B, "z.e"), strcpy(A, "a")), 0); EXPECT_LT(CompareDnsNames(strcpy(B, "aaa.example"), strcpy(A, "zzz")), 0); EXPECT_LT(CompareDnsNames(strcpy(B, "zzz.example"), strcpy(A, "aaa")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "zzz"), strcpy(B, "aaa.example")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "aaa"), strcpy(B, "zzz.example")), 0); free(B); free(A); } TEST(CompareDnsNames, testLikelySubdomain_alwaysComesAfterSld) { char *A = malloc(16); char *B = malloc(16); EXPECT_LT(CompareDnsNames(strcpy(B, "a.e"), strcpy(A, "z.a.e")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "z.a.e"), strcpy(B, "a.e")), 0); EXPECT_LT(CompareDnsNames(strcpy(B, "b.e"), strcpy(A, "a.b.e")), 0); EXPECT_GT(CompareDnsNames(strcpy(A, "a.b.e"), strcpy(B, "b.e")), 0); free(B); free(A); }
5,176
111
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/dnsquestion_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/dns.h" #include "libc/dns/dnsquestion.h" #include "libc/errno.h" #include "libc/mem/mem.h" #include "libc/testlib/testlib.h" TEST(SerializeDnsQuestion, test) { struct DnsQuestion dq; char name[] = "foo.bar"; uint8_t buf[1 + 3 + 1 + 3 + 1 + 4]; dq.qname = name; dq.qtype = 0x0201; dq.qclass = 0x0102; EXPECT_EQ(1 + 3 + 1 + 3 + 1 + 4, SerializeDnsQuestion(buf, 1 + 3 + 1 + 3 + 1 + 4, &dq)); EXPECT_BINEQ(u"♥foo♥bar ☻☺☺☻", buf); } TEST(SerializeDnsQuestion, testNoSpace) { struct DnsQuestion dq; char name[] = "foo.bar"; uint8_t buf[1 + 3 + 1 + 3 + 1 + 3]; dq.qname = name; dq.qtype = 0x0201; dq.qclass = 0x0102; EXPECT_EQ(-1, SerializeDnsQuestion(buf, 1 + 3 + 1 + 3 + 1 + 3, &dq)); EXPECT_EQ(ENOSPC, errno); }
2,622
47
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/dnsheader_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/dns.h" #include "libc/dns/dnsheader.h" #include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" TEST(SerializeDnsHeader, test) { uint8_t buf[12]; struct DnsHeader header; memset(&header, 0, sizeof(header)); header.id = 255; header.bf1 = true; header.qdcount = 1; SerializeDnsHeader(buf, &header); EXPECT_BINEQ(u" λ☺  ☺      ", buf); } TEST(SerializeDnsHeader, fuzzSymmetry) { uint8_t buf[12]; struct DnsHeader in, out; rngset(&in, sizeof(in), _rand64, -1); rngset(&out, sizeof(out), _rand64, -1); SerializeDnsHeader(buf, &in); DeserializeDnsHeader(&out, buf); ASSERT_EQ(0, memcmp(&in, &out, 12), "%#.*s\n\t%#.*s", 12, in, 12, buf); }
2,657
48
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/parsehoststxt_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/hoststxt.h" #include "libc/mem/mem.h" #include "libc/sock/sock.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/testlib/testlib.h" static const char *parseip(unsigned char ip[4]) { static char g_ipbuf[16]; return inet_ntop(AF_INET, ip, g_ipbuf, sizeof(g_ipbuf)); } TEST(ParseHostsTxt, testEmpty) { struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt)); FILE *f = fmemopen(NULL, BUFSIZ, "r+"); ASSERT_EQ(0, ParseHostsTxt(ht, f)); ASSERT_EQ(0, ht->entries.i); FreeHostsTxt(&ht); fclose(f); } TEST(ParseHostsTxt, testCorrectlyTokenizesAndSorts) { const char kInput[] = "# this is a comment\n" "# IP HOST1 HOST2\n" "203.0.113.1 lol.example. lol\n" "203.0.113.2 cat.example. cat\n"; struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt)); FILE *f = fmemopen(NULL, BUFSIZ, "r+"); ASSERT_EQ(1, fwrite(kInput, strlen(kInput), 1, f)); rewind(f); ASSERT_EQ(0, ParseHostsTxt(ht, f)); ASSERT_EQ(4, ht->entries.i); EXPECT_STREQ("lol.example.", &ht->strings.p[ht->entries.p[0].name]); EXPECT_STREQ("lol.example.", &ht->strings.p[ht->entries.p[0].canon]); EXPECT_STREQ("203.0.113.1", parseip(ht->entries.p[0].ip)); EXPECT_STREQ("lol", &ht->strings.p[ht->entries.p[1].name]); EXPECT_STREQ("lol.example.", &ht->strings.p[ht->entries.p[1].canon]); EXPECT_STREQ("203.0.113.1", parseip(ht->entries.p[1].ip)); EXPECT_STREQ("cat.example.", &ht->strings.p[ht->entries.p[2].name]); EXPECT_STREQ("cat.example.", &ht->strings.p[ht->entries.p[2].canon]); EXPECT_STREQ("203.0.113.2", parseip(ht->entries.p[2].ip)); EXPECT_STREQ("cat", &ht->strings.p[ht->entries.p[3].name]); EXPECT_STREQ("cat.example.", &ht->strings.p[ht->entries.p[3].canon]); EXPECT_STREQ("203.0.113.2", parseip(ht->entries.p[3].ip)); FreeHostsTxt(&ht); fclose(f); } TEST(ParseHostsTxt, testIpv6_isIgnored) { const char kInput[] = "::1 boop\n" "203.0.113.2 cat # ignore me\n"; struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt)); FILE *f = fmemopen(kInput, strlen(kInput), "r+"); ASSERT_EQ(0, ParseHostsTxt(ht, f)); ASSERT_EQ(1, ht->entries.i); EXPECT_STREQ("cat", &ht->strings.p[ht->entries.p[0].name]); EXPECT_STREQ("cat", &ht->strings.p[ht->entries.p[0].canon]); EXPECT_STREQ("203.0.113.2", parseip(ht->entries.p[0].ip)); FreeHostsTxt(&ht); fclose(f); }
4,338
81
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/prototxt_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ This is free and unencumbered software released into the public domain. │ │ │ │ Anyone is free to copy, modify, publish, use, compile, sell, or │ │ distribute this software, either in source code form or as a compiled │ │ binary, for any purpose, commercial or non-commercial, and by any │ │ means. │ │ │ │ In jurisdictions that recognize copyright laws, the author or authors │ │ of this software dedicate any and all copyright interest in the │ │ software to the public domain. We make this dedication for the benefit │ │ of the public at large and to the detriment of our heirs and │ │ successors. We intend this dedication to be an overt act of │ │ relinquishment in perpetuity of all present and future rights to this │ │ software under copyright law. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │ │ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │ │ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │ │ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR │ │ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │ │ OTHER DEALINGS IN THE SOFTWARE. │ │ │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/dns/dns.h" #include "libc/dns/ent.h" #include "libc/dns/prototxt.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" char testlib_enable_tmp_setup_teardown; void SetUp() { int fd; const char *sample = "\ # skip comment string\n\ rspf 73 RSPF CPHB \n\ ggp 3 GGP "; ASSERT_NE(-1, (fd = creat("protocols", 0755))); ASSERT_NE(-1, write(fd, sample, strlen(sample))); ASSERT_NE(-1, close(fd)); } TEST(LookupProtoByNumber, GetNameWhenNumberCorrect) { char name[16]; /* sample has only names of length 3-4 */ strcpy(name, ""); ASSERT_EQ(-1, /*non-existent number */ LookupProtoByNumber(24, name, sizeof(name), "protocols")); ASSERT_EQ(-1, /* sizeof(name) insufficient, memccpy failure */ LookupProtoByNumber(73, name, 1, "protocols")); ASSERT_STREQ(name, ""); /* cleaned up after memccpy failed */ ASSERT_EQ(0, /* works with valid number */ LookupProtoByNumber(73, name, sizeof(name), "protocols")); ASSERT_STREQ(name, "rspf"); /* official name written */ } TEST(LookupProtoByName, GetNumberWhenNameOrAlias) { char name[16]; /* sample has only names of length 3-4 */ strcpy(name, ""); ASSERT_EQ(-1, /* non-existent name or alias */ LookupProtoByName("tcp", name, sizeof(name), "protocols")); ASSERT_EQ(-1, /* sizeof(name) insufficient, memccpy failure */ LookupProtoByName("ggp", name, 1, "protocols")); ASSERT_STREQ(name, ""); /* cleaned up after memccpy failed */ ASSERT_EQ(3, /* works with valid name */ LookupProtoByName("ggp", name, sizeof(name), "protocols")); ASSERT_STREQ(name, "ggp"); ASSERT_EQ(73, /* works with valid alias */ LookupProtoByName("CPHB", name, sizeof(name), "protocols")); ASSERT_STREQ(name, "rspf"); /* official name written */ }
4,496
77
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/pascalifydnsname_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/dns.h" #include "libc/errno.h" #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" TEST(PascalifyDnsName, testEmpty) { uint8_t *buf = malloc(1); char *name = strdup(""); EXPECT_EQ(0, PascalifyDnsName(buf, 1, name)); EXPECT_BINEQ(u" ", buf); free(name); free(buf); } TEST(PascalifyDnsName, testOneLabel) { uint8_t *buf = malloc(1 + 3 + 1); char *name = strdup("foo"); EXPECT_EQ(1 + 3, PascalifyDnsName(buf, 1 + 3 + 1, name)); EXPECT_BINEQ(u"♥foo ", buf); free(name); free(buf); } TEST(PascalifyDnsName, testTwoLabels) { uint8_t *buf = malloc(1 + 3 + 1 + 3 + 1); char *name = strdup("foo.bar"); EXPECT_EQ(1 + 3 + 1 + 3, PascalifyDnsName(buf, 1 + 3 + 1 + 3 + 1, name)); EXPECT_BINEQ(u"♥foo♥bar ", buf); free(name); free(buf); } TEST(PascalifyDnsName, testFqdnDot_isntIncluded) { uint8_t *buf = malloc(1 + 3 + 1 + 3 + 1); char *name = strdup("foo.bar."); EXPECT_EQ(1 + 3 + 1 + 3, PascalifyDnsName(buf, 1 + 3 + 1 + 3 + 1, name)); EXPECT_BINEQ(u"♥foo♥bar ", buf); free(name); free(buf); } TEST(PascalifyDnsName, testTooLong) { uint8_t *buf = malloc(1); char *name = malloc(1000); memset(name, '.', 999); name[999] = '\0'; EXPECT_EQ(-1, PascalifyDnsName(buf, 1, name)); EXPECT_EQ(ENAMETOOLONG, errno); free(name); free(buf); } TEST(PascalifyDnsName, testNoSpace) { uint8_t *buf = malloc(1); char *name = strdup("foo"); EXPECT_EQ(-1, PascalifyDnsName(buf, 1, name)); EXPECT_EQ(ENOSPC, errno); free(name); free(buf); }
3,395
80
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/parseresolvconf_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/dns.h" #include "libc/dns/hoststxt.h" #include "libc/dns/resolvconf.h" #include "libc/mem/mem.h" #include "libc/sock/sock.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/testlib/testlib.h" static const char *FormatIp(struct sockaddr_in *ip) { static char g_ipbuf[16]; return inet_ntop(ip->sin_family, &ip->sin_addr.s_addr, g_ipbuf, 16); } TEST(ParseResolvConf, testEmpty) { struct ResolvConf *rv = calloc(1, sizeof(struct ResolvConf)); FILE *f = fmemopen(NULL, BUFSIZ, "r+"); ASSERT_EQ(0, ParseResolvConf(rv, f)); ASSERT_EQ(0, rv->nameservers.i); FreeResolvConf(&rv); fclose(f); } TEST(ParseResolvConf, testCorrectlyTokenizes) { const char kInput[] = "# this is a comment\n" "nameserver 203.0.113.2 \n" " nameserver 203.0.113.1\n"; struct ResolvConf *rv = calloc(1, sizeof(struct ResolvConf)); FILE *f = fmemopen(kInput, strlen(kInput), "r+"); ASSERT_EQ(2, ParseResolvConf(rv, f)); ASSERT_EQ(2, rv->nameservers.i); EXPECT_EQ(AF_INET, rv->nameservers.p[0].sin_family); EXPECT_EQ(DNS_PORT, ntohs(rv->nameservers.p[0].sin_port)); EXPECT_STREQ("203.0.113.2", FormatIp(&rv->nameservers.p[0])); EXPECT_EQ(AF_INET, rv->nameservers.p[1].sin_family); EXPECT_EQ(DNS_PORT, ntohs(rv->nameservers.p[1].sin_port)); EXPECT_STREQ("203.0.113.1", FormatIp(&rv->nameservers.p[1])); FreeResolvConf(&rv); fclose(f); } TEST(ParseResolvConf, testMulticastDnsThing_getsIgnored) { const char kInput[] = "search local # boop\n"; struct ResolvConf *rv = calloc(1, sizeof(struct ResolvConf)); FILE *f = fmemopen(NULL, BUFSIZ, "r+"); ASSERT_EQ(strlen(kInput), fwrite(kInput, 1, strlen(kInput), f)); ASSERT_EQ(0, ParseResolvConf(rv, f)); ASSERT_EQ(0, rv->nameservers.i); FreeResolvConf(&rv); fclose(f); }
3,701
71
jart/cosmopolitan
false
cosmopolitan/test/libc/dns/test.mk
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ #───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ PKGS += TEST_LIBC_DNS TEST_LIBC_DNS_SRCS := $(wildcard test/libc/dns/*.c) TEST_LIBC_DNS_SRCS_TEST = $(filter %_test.c,$(TEST_LIBC_DNS_SRCS)) TEST_LIBC_DNS_OBJS = \ $(TEST_LIBC_DNS_SRCS:%.c=o/$(MODE)/%.o) TEST_LIBC_DNS_COMS = \ $(TEST_LIBC_DNS_SRCS:%.c=o/$(MODE)/%.com) TEST_LIBC_DNS_BINS = \ $(TEST_LIBC_DNS_COMS) \ $(TEST_LIBC_DNS_COMS:%=%.dbg) TEST_LIBC_DNS_TESTS = \ $(TEST_LIBC_DNS_SRCS_TEST:%.c=o/$(MODE)/%.com.ok) TEST_LIBC_DNS_CHECKS = \ $(TEST_LIBC_DNS_SRCS_TEST:%.c=o/$(MODE)/%.com.runs) TEST_LIBC_DNS_DIRECTDEPS = \ LIBC_CALLS \ LIBC_DNS \ LIBC_FMT \ LIBC_INTRIN \ LIBC_LOG \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ LIBC_SOCK \ LIBC_STDIO \ LIBC_STR \ LIBC_STUBS \ LIBC_SYSV \ LIBC_TESTLIB \ LIBC_X TEST_LIBC_DNS_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_DNS_DIRECTDEPS),$($(x)))) o/$(MODE)/test/libc/dns/dns.pkg: \ $(TEST_LIBC_DNS_OBJS) \ $(foreach x,$(TEST_LIBC_DNS_DIRECTDEPS),$($(x)_A).pkg) o/$(MODE)/test/libc/dns/%.com.dbg: \ $(TEST_LIBC_DNS_DEPS) \ o/$(MODE)/test/libc/dns/%.o \ o/$(MODE)/test/libc/dns/dns.pkg \ $(LIBC_TESTMAIN) \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) .PHONY: o/$(MODE)/test/libc/dns o/$(MODE)/test/libc/dns: \ $(TEST_LIBC_DNS_BINS) \ $(TEST_LIBC_DNS_CHECKS)
1,567
62
jart/cosmopolitan
false
cosmopolitan/test/libc/thread/pthread_create_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/atomic.h" #include "libc/calls/calls.h" #include "libc/calls/struct/sched_param.h" #include "libc/calls/struct/sigaction.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/macros.internal.h" #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/nexgen32e/vendor.internal.h" #include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" #include "libc/sysv/consts/prot.h" #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/subprocess.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" #include "libc/thread/thread2.h" void OnUsr1(int sig, struct siginfo *si, void *vctx) { struct ucontext *ctx = vctx; } void SetUp(void) { struct sigaction sig = {.sa_sigaction = OnUsr1, .sa_flags = SA_SIGINFO}; sigaction(SIGUSR1, &sig, 0); } void TriggerSignal(void) { sched_yield(); raise(SIGUSR1); sched_yield(); } static void *Increment(void *arg) { ASSERT_EQ(gettid(), pthread_getthreadid_np()); TriggerSignal(); return (void *)((uintptr_t)arg + 1); } TEST(pthread_create, testCreateReturnJoin) { void *rc; pthread_t id; ASSERT_EQ(0, pthread_create(&id, 0, Increment, (void *)1)); ASSERT_EQ(0, pthread_join(id, &rc)); ASSERT_EQ((void *)2, rc); } static void *IncExit(void *arg) { CheckStackIsAligned(); TriggerSignal(); pthread_exit((void *)((uintptr_t)arg + 1)); } TEST(pthread_create, testCreateExitJoin) { void *rc; pthread_t id; ASSERT_EQ(0, pthread_create(&id, 0, IncExit, (void *)2)); ASSERT_EQ(0, pthread_join(id, &rc)); ASSERT_EQ((void *)3, rc); } static void *CheckSchedule(void *arg) { int rc, policy; struct sched_param prio; ASSERT_EQ(0, pthread_getschedparam(pthread_self(), &policy, &prio)); ASSERT_EQ(SCHED_OTHER, policy); ASSERT_EQ(sched_get_priority_min(SCHED_OTHER), prio.sched_priority); if (IsWindows() || IsXnu() || IsOpenbsd()) { ASSERT_EQ(ENOSYS, pthread_setschedparam(pthread_self(), policy, &prio)); } else { ASSERT_EQ(0, pthread_setschedparam(pthread_self(), policy, &prio)); } return 0; } TEST(pthread_create, scheduling) { pthread_t id; pthread_attr_t attr; struct sched_param pri = {sched_get_priority_min(SCHED_OTHER)}; ASSERT_EQ(0, pthread_attr_init(&attr)); ASSERT_EQ(0, pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED)); ASSERT_EQ(0, pthread_attr_setschedpolicy(&attr, SCHED_OTHER)); ASSERT_EQ(0, pthread_attr_setschedparam(&attr, &pri)); ASSERT_EQ(0, pthread_create(&id, &attr, CheckSchedule, 0)); ASSERT_EQ(0, pthread_attr_destroy(&attr)); ASSERT_EQ(0, pthread_join(id, 0)); } static void *CheckStack(void *arg) { char buf[1024 * 1024]; TriggerSignal(); CheckLargeStackAllocation(buf, 1024 * 1024); return 0; } TEST(pthread_create, testBigStack) { pthread_t id; pthread_attr_t attr; ASSERT_EQ(0, pthread_attr_init(&attr)); ASSERT_EQ(0, pthread_attr_setstacksize(&attr, 2 * 1000 * 1000)); ASSERT_EQ(0, pthread_create(&id, &attr, CheckStack, 0)); ASSERT_EQ(0, pthread_attr_destroy(&attr)); ASSERT_EQ(0, pthread_join(id, 0)); } static void *CheckStack2(void *arg) { char buf[57244]; TriggerSignal(); CheckLargeStackAllocation(buf, sizeof(buf)); return 0; } TEST(pthread_create, testBiggerGuardSize) { pthread_t id; pthread_attr_t attr; ASSERT_EQ(0, pthread_attr_init(&attr)); ASSERT_EQ(0, pthread_attr_setstacksize(&attr, 65536)); ASSERT_EQ(0, pthread_attr_setguardsize(&attr, 8192)); ASSERT_EQ(0, pthread_create(&id, &attr, CheckStack2, 0)); ASSERT_EQ(0, pthread_attr_destroy(&attr)); ASSERT_EQ(0, pthread_join(id, 0)); } TEST(pthread_create, testCustomStack_withReallySmallSize) { char *stk; size_t siz; pthread_t id; pthread_attr_t attr; siz = PTHREAD_STACK_MIN; stk = malloc(siz); ASSERT_EQ(0, pthread_attr_init(&attr)); ASSERT_EQ(0, pthread_attr_setstack(&attr, stk, siz)); ASSERT_EQ(0, pthread_create(&id, &attr, Increment, 0)); ASSERT_EQ(0, pthread_attr_destroy(&attr)); ASSERT_EQ(0, pthread_join(id, 0)); // we still own the stack memory ASSERT_EQ(0, pthread_attr_init(&attr)); ASSERT_EQ(0, pthread_attr_setstack(&attr, stk, siz)); ASSERT_EQ(0, pthread_create(&id, &attr, Increment, 0)); ASSERT_EQ(0, pthread_attr_destroy(&attr)); ASSERT_EQ(0, pthread_join(id, 0)); free(stk); } void *JoinMainWorker(void *arg) { void *rc; pthread_t main_thread = (pthread_t)arg; _gc(malloc(32)); _gc(malloc(32)); ASSERT_EQ(0, pthread_join(main_thread, &rc)); ASSERT_EQ(123, (intptr_t)rc); return 0; } TEST(pthread_join, mainThread) { pthread_t id; _gc(malloc(32)); _gc(malloc(32)); SPAWN(fork); ASSERT_EQ(0, pthread_create(&id, 0, JoinMainWorker, (void *)pthread_self())); pthread_exit((void *)123); EXITS(0); } TEST(pthread_join, mainThreadDelayed) { pthread_t id; _gc(malloc(32)); _gc(malloc(32)); SPAWN(fork); ASSERT_EQ(0, pthread_create(&id, 0, JoinMainWorker, (void *)pthread_self())); usleep(10000); pthread_exit((void *)123); EXITS(0); } TEST(pthread_exit, fromMainThread_whenNoThreadsWereCreated) { SPAWN(fork); pthread_exit((void *)123); EXITS(0); } atomic_int g_cleanup1; atomic_int g_cleanup2; void OnCleanup(void *arg) { *(atomic_int *)arg = true; } void *CleanupExit(void *arg) { pthread_cleanup_push(OnCleanup, &g_cleanup1); pthread_cleanup_push(OnCleanup, &g_cleanup2); pthread_cleanup_pop(false); pthread_exit(0); pthread_cleanup_pop(false); return 0; } TEST(pthread_cleanup, pthread_exit_alwaysCallsCallback) { pthread_t id; g_cleanup1 = false; g_cleanup2 = false; ASSERT_EQ(0, pthread_create(&id, 0, CleanupExit, 0)); ASSERT_EQ(0, pthread_join(id, 0)); ASSERT_TRUE(g_cleanup1); ASSERT_FALSE(g_cleanup2); } void *CleanupNormal(void *arg) { pthread_cleanup_push(OnCleanup, &g_cleanup1); pthread_cleanup_push(OnCleanup, &g_cleanup2); pthread_cleanup_pop(true); pthread_cleanup_pop(true); return 0; } TEST(pthread_cleanup, pthread_normal) { pthread_t id; g_cleanup1 = false; g_cleanup2 = false; ASSERT_EQ(0, pthread_create(&id, 0, CleanupNormal, 0)); ASSERT_EQ(0, pthread_join(id, 0)); ASSERT_TRUE(g_cleanup1); ASSERT_TRUE(g_cleanup2); } //////////////////////////////////////////////////////////////////////////////// // BENCHMARKS static void CreateJoin(void) { pthread_t id; ASSERT_EQ(0, pthread_create(&id, 0, Increment, 0)); ASSERT_EQ(0, pthread_join(id, 0)); } // this is de facto the same as create+join static void CreateDetach(void) { pthread_t id; ASSERT_EQ(0, pthread_create(&id, 0, Increment, 0)); ASSERT_EQ(0, pthread_detach(id)); } // this is really fast static void CreateDetached(void) { pthread_t th; pthread_attr_t attr; ASSERT_EQ(0, pthread_attr_init(&attr)); ASSERT_EQ(0, pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)); ASSERT_EQ(0, pthread_create(&th, &attr, Increment, 0)); ASSERT_EQ(0, pthread_attr_destroy(&attr)); } BENCH(pthread_create, bench) { EZBENCH2("CreateJoin", donothing, CreateJoin()); EZBENCH2("CreateDetach", donothing, CreateDetach()); EZBENCH2("CreateDetached", donothing, CreateDetached()); while (!pthread_orphan_np()) { pthread_decimate_np(); } }
9,126
283
jart/cosmopolitan
false
cosmopolitan/test/libc/thread/sem_open_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/kprintf.h" #include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/temp.h" #include "libc/str/str.h" #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/o.h" #include "libc/testlib/subprocess.h" #include "libc/testlib/testlib.h" #include "libc/thread/semaphore.h" #include "libc/thread/thread.h" pthread_barrier_t barrier; char testlib_enable_tmp_setup_teardown; void SetUp(void) { // TODO(jart): Fix shocking GitHub Actions error. if (getenv("CI")) exit(0); sem_unlink("/fooz"); sem_unlink("/barz"); } void IgnoreStderr(void) { close(2); open("/dev/null", O_WRONLY); } void *Worker(void *arg) { sem_t *a, *b; struct timespec ts; ASSERT_NE(SEM_FAILED, (a = sem_open("/fooz", 0))); ASSERT_EQ((sem_t *)arg, a); ASSERT_NE(SEM_FAILED, (b = sem_open("/barz", 0))); if (pthread_barrier_wait(&barrier) == PTHREAD_BARRIER_SERIAL_THREAD) { ASSERT_SYS(0, 0, sem_unlink("/fooz")); } ASSERT_SYS(0, 0, clock_gettime(CLOCK_REALTIME, &ts)); ts.tv_sec += 1; ASSERT_SYS(0, 0, sem_post(a)); ASSERT_SYS(0, 0, sem_timedwait(b, &ts)); ASSERT_SYS(0, 0, sem_close(b)); ASSERT_TRUE(testlib_memoryexists(b)); ASSERT_SYS(0, 0, sem_close(a)); ASSERT_TRUE(testlib_memoryexists(a)); return 0; } // 1. multiple threads opening same name must yield same address // 2. semaphore memory is freed, when all threads have closed it // 3. semaphore may be unlinked before it's closed, from creator // 4. semaphore may be unlinked before it's closed, from threads TEST(sem_open, test) { sem_t *a, *b; int i, r, n = 4; pthread_t *t = _gc(malloc(sizeof(pthread_t) * n)); sem_unlink("/fooz"); sem_unlink("/barz"); errno = 0; ASSERT_EQ(0, pthread_barrier_init(&barrier, 0, n)); ASSERT_NE(SEM_FAILED, (a = sem_open("/fooz", O_CREAT, 0644, 0))); ASSERT_NE(SEM_FAILED, (b = sem_open("/barz", O_CREAT, 0644, 0))); ASSERT_SYS(0, 0, sem_getvalue(a, &r)); ASSERT_EQ(0, r); ASSERT_SYS(0, 0, sem_getvalue(b, &r)); ASSERT_EQ(0, r); for (i = 0; i < n; ++i) ASSERT_EQ(0, pthread_create(t + i, 0, Worker, a)); for (i = 0; i < n; ++i) ASSERT_SYS(0, 0, sem_wait(a)); ASSERT_SYS(0, 0, sem_getvalue(a, &r)); ASSERT_EQ(0, r); for (i = 0; i < n; ++i) ASSERT_SYS(0, 0, sem_post(b)); for (i = 0; i < n; ++i) ASSERT_EQ(0, pthread_join(t[i], 0)); ASSERT_SYS(0, 0, sem_unlink("/barz")); ASSERT_SYS(0, 0, sem_getvalue(b, &r)); ASSERT_EQ(0, r); ASSERT_SYS(0, 0, sem_close(b)); ASSERT_FALSE(testlib_memoryexists(b)); ASSERT_SYS(0, 0, sem_close(a)); ASSERT_FALSE(testlib_memoryexists(a)); ASSERT_EQ(0, pthread_barrier_destroy(&barrier)); } TEST(sem_close, withUnnamedSemaphore_isUndefinedBehavior) { if (!IsModeDbg()) return; sem_t sem; ASSERT_SYS(0, 0, sem_init(&sem, 0, 0)); SPAWN(fork); IgnoreStderr(); sem_close(&sem); EXITS(77); ASSERT_SYS(0, 0, sem_destroy(&sem)); } TEST(sem_destroy, withNamedSemaphore_isUndefinedBehavior) { if (!IsModeDbg()) return; sem_t *sem; ASSERT_NE(SEM_FAILED, (sem = sem_open("/boop", O_CREAT, 0644, 0))); SPAWN(fork); IgnoreStderr(); sem_destroy(sem); EXITS(77); ASSERT_SYS(0, 0, sem_unlink("/boop")); ASSERT_SYS(0, 0, sem_close(sem)); } TEST(sem_open, inheritAcrossFork) { sem_t *a, *b; struct timespec ts; ASSERT_SYS(0, 0, clock_gettime(CLOCK_REALTIME, &ts)); ts.tv_sec += 1; errno = 0; ASSERT_NE(SEM_FAILED, (a = sem_open("/fooz", O_CREAT, 0644, 0))); ASSERT_SYS(0, 0, sem_unlink("/fooz")); ASSERT_NE(SEM_FAILED, (b = sem_open("/barz", O_CREAT, 0644, 0))); ASSERT_SYS(0, 0, sem_unlink("/barz")); SPAWN(fork); ASSERT_SYS(0, 0, sem_post(a)); ASSERT_SYS(0, 0, sem_wait(b)); PARENT(); ASSERT_SYS(0, 0, sem_wait(a)); ASSERT_SYS(0, 0, sem_post(b)); WAIT(exit, 0); ASSERT_SYS(0, 0, sem_close(b)); ASSERT_FALSE(testlib_memoryexists(b)); ASSERT_SYS(0, 0, sem_close(a)); ASSERT_FALSE(testlib_memoryexists(a)); } TEST(sem_open, openReadonlyAfterUnlink_enoent) { sem_t *sem; sem_unlink("/fooz"); ASSERT_NE(SEM_FAILED, (sem = sem_open("/fooz", O_CREAT, 0644, 0))); ASSERT_EQ(0, sem_unlink("/fooz")); ASSERT_EQ(SEM_FAILED, sem_open("/fooz", O_RDONLY)); ASSERT_EQ(ENOENT, errno); ASSERT_EQ(0, sem_close(sem)); } TEST(sem_open, openReadonlyAfterIndependentUnlinkAndRecreate_returnsNewOne) { if (1) return; sem_t *a, *b; ASSERT_NE(SEM_FAILED, (a = sem_open("/fooz", O_CREAT, 0644, 0))); SPAWN(fork); ASSERT_EQ(0, sem_unlink("/fooz")); ASSERT_NE(SEM_FAILED, (b = sem_open("/fooz", O_CREAT, 0644, 0))); ASSERT_NE(a, b); ASSERT_SYS(0, 0, sem_post(a)); ASSERT_SYS(0, 0, sem_wait(b)); ASSERT_EQ(0, sem_close(b)); PARENT(); ASSERT_SYS(0, 0, sem_wait(a)); ASSERT_NE(SEM_FAILED, (b = sem_open("/fooz", O_RDONLY))); ASSERT_NE(a, b); ASSERT_SYS(0, 0, sem_post(b)); ASSERT_EQ(0, sem_close(b)); WAIT(exit, 0); ASSERT_EQ(0, sem_close(a)); } TEST(sem_close, openTwiceCloseOnce_stillMapped) { if (1) return; sem_t *a, *b; char name[] = "smXXXXXX"; ASSERT_NE(NULL, mktemp(name)); ASSERT_NE(SEM_FAILED, (a = sem_open(name, O_CREAT | O_EXCL, 0600, 0))); ASSERT_NE(SEM_FAILED, (b = sem_open(name, 0))); ASSERT_SYS(0, 0, sem_unlink(name)); ASSERT_SYS(0, 0, sem_close(a)); ASSERT_SYS(0, 0, sem_post(a)); ASSERT_SYS(0, 0, sem_close(b)); }
7,189
192
jart/cosmopolitan
false
cosmopolitan/test/libc/thread/pthread_cond_signal_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/timespec.h" #include "libc/errno.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" #include "libc/thread/thread2.h" // TODO(jart): Can we make this test go faster on NetBSD? int pos; int count; int limit; long data[1000]; pthread_mutex_t mu; pthread_cond_t non_full; pthread_cond_t non_empty; int Put(long v, struct timespec *abs_deadline) { int err, added = 0, wake = 0; pthread_mutex_lock(&mu); while (count == limit) { if ((err = pthread_cond_timedwait(&non_full, &mu, abs_deadline))) { ASSERT_EQ(ETIMEDOUT, err); ASSERT_NE(NULL, abs_deadline); } } if (count != limit) { int i = pos + count; if (limit <= i) i -= limit; data[i] = v; if (count == 0) wake = 1; count++; added = 1; } pthread_mutex_unlock(&mu); if (wake) pthread_cond_broadcast(&non_empty); return added; } long Get(struct timespec *abs_deadline) { long err, v = 0; pthread_mutex_lock(&mu); while (!count) { if ((err = pthread_cond_timedwait(&non_empty, &mu, abs_deadline))) { ASSERT_EQ(ETIMEDOUT, err); ASSERT_NE(NULL, abs_deadline); } } if (count) { v = data[pos]; data[pos] = 0; if (count == limit) { pthread_cond_broadcast(&non_full); } pos++; count--; if (pos == limit) { pos = 0; } } pthread_mutex_unlock(&mu); return v; } #define N 1000 void *Producer(void *arg) { for (int i = 0; i < N; i++) { ASSERT_EQ(1, Put((i + 1) * 3, 0)); } return 0; } void *Consumer(void *arg) { for (int i = 0; i < N; i++) { ASSERT_EQ((i + 1) * 3, Get(0)); } return 0; } TEST(cond, test) { pthread_t t; limit = 1; ASSERT_EQ(0, pthread_create(&t, 0, Producer, 0)); Consumer(0); ASSERT_EQ(0, pthread_join(t, 0)); limit = 10; ASSERT_EQ(0, pthread_create(&t, 0, Producer, 0)); Consumer(0); ASSERT_EQ(0, pthread_join(t, 0)); limit = 100; ASSERT_EQ(0, pthread_create(&t, 0, Producer, 0)); Consumer(0); ASSERT_EQ(0, pthread_join(t, 0)); limit = 1000; ASSERT_EQ(0, pthread_create(&t, 0, Producer, 0)); Consumer(0); ASSERT_EQ(0, pthread_join(t, 0)); }
3,984
121
jart/cosmopolitan
false
cosmopolitan/test/libc/thread/pthread_setname_np_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/atomic.h" #include "libc/dce.h" #include "libc/intrin/atomic.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" static void *SetName(void *arg) { ASSERT_EQ(0, pthread_setname_np(pthread_self(), "justine")); return 0; } TEST(pthread_setname_np, SetName_SystemCallSucceeds) { pthread_t id; if (!IsLinux() || !IsNetbsd() || !IsFreebsd()) return; ASSERT_EQ(0, pthread_create(&id, 0, SetName, 0)); ASSERT_EQ(0, pthread_join(id, 0)); } static void *SetGetNameOfSelf(void *arg) { char me[16]; ASSERT_EQ(0, pthread_setname_np(pthread_self(), "justine")); ASSERT_EQ(0, pthread_getname_np(pthread_self(), me, sizeof(me))); EXPECT_STREQ("justine", me); return 0; } TEST(pthread_setname_np, SetGetNameOfSelf) { pthread_t id; if (!IsLinux() || !IsNetbsd()) return; ASSERT_EQ(0, pthread_create(&id, 0, SetGetNameOfSelf, 0)); ASSERT_EQ(0, pthread_join(id, 0)); } static void *GetDefaultName(void *arg) { char me[16]; ASSERT_EQ(0, pthread_getname_np(pthread_self(), me, sizeof(me))); EXPECT_STREQ("", me); return 0; } TEST(pthread_setname_np, GetDefaultName_IsEmptyString) { pthread_t id; if (!IsLinux() || !IsNetbsd()) return; ASSERT_EQ(0, pthread_create(&id, 0, GetDefaultName, 0)); ASSERT_EQ(0, pthread_join(id, 0)); } atomic_char sync1, sync2; static void *GetNameOfOtherThreadWorker(void *arg) { pthread_setname_np(pthread_self(), "justine"); atomic_store(&sync1, 1); while (!atomic_load(&sync2)) pthread_yield(); return 0; } TEST(pthread_setname_np, GetNameOfOtherThread) { char me[16]; pthread_t id; if (!IsLinux() || !IsNetbsd()) return; ASSERT_EQ(0, pthread_create(&id, 0, GetNameOfOtherThreadWorker, 0)); while (!atomic_load(&sync1)) pthread_yield(); ASSERT_EQ(0, pthread_getname_np(id, me, sizeof(me))); EXPECT_STREQ("justine", me); ASSERT_EQ(0, pthread_setname_np(id, "tunney")); ASSERT_EQ(0, pthread_getname_np(id, me, sizeof(me))); EXPECT_STREQ("tunney", me); atomic_store(&sync2, 1); ASSERT_EQ(0, pthread_join(id, 0)); }
3,876
89
jart/cosmopolitan
false
cosmopolitan/test/libc/thread/pthread_key_create_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/atomic.h" #include "libc/intrin/kprintf.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" pthread_key_t mykey; int destructor_calls; void KeyDestructor(void *arg) { EXPECT_EQ(0, pthread_getspecific(mykey)); ASSERT_EQ(31337, (intptr_t)arg); ++destructor_calls; } void *Worker(void *arg) { ASSERT_EQ(0, pthread_getspecific(mykey)); ASSERT_EQ(0, pthread_setspecific(mykey, (void *)31337)); ASSERT_EQ((void *)31337, pthread_getspecific(mykey)); return 0; } TEST(pthread_key_create, test) { pthread_t th; destructor_calls = 0; ASSERT_EQ(0, pthread_key_create(&mykey, KeyDestructor)); ASSERT_EQ(0, pthread_setspecific(mykey, (void *)666)); ASSERT_EQ(0, pthread_create(&th, 0, Worker, 0)); ASSERT_EQ(0, pthread_join(th, 0)); ASSERT_EQ(1, destructor_calls); ASSERT_EQ((void *)666, pthread_getspecific(mykey)); ASSERT_EQ(0, pthread_key_delete(mykey)); } void KeyDestructorCraze(void *arg) { EXPECT_EQ(0, pthread_getspecific(mykey)); ASSERT_EQ(31337, (intptr_t)arg); EXPECT_EQ(0, pthread_setspecific(mykey, (void *)31337)); ++destructor_calls; } TEST(pthread_key_create, destructorKeepsSettingKey_willHalt) { pthread_t th; destructor_calls = 0; ASSERT_EQ(0, pthread_key_create(&mykey, KeyDestructorCraze)); ASSERT_EQ(0, pthread_setspecific(mykey, (void *)666)); ASSERT_EQ(0, pthread_create(&th, 0, Worker, 0)); ASSERT_EQ(0, pthread_join(th, 0)); ASSERT_EQ(PTHREAD_DESTRUCTOR_ITERATIONS, destructor_calls); ASSERT_EQ((void *)666, pthread_getspecific(mykey)); ASSERT_EQ(0, pthread_key_delete(mykey)); }
3,489
72
jart/cosmopolitan
false
cosmopolitan/test/libc/thread/nsync_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" #include "third_party/nsync/cv.h" #include "third_party/nsync/mu.h" int pos; int count; int limit; long data[1000]; nsync_mu mu; nsync_cv non_full; nsync_cv non_empty; int Put(long v, nsync_time abs_deadline) { int err, added = 0, wake = 0; nsync_mu_lock(&mu); while (count == limit) { if ((err = nsync_cv_wait_with_deadline(&non_full, &mu, abs_deadline, 0))) { ASSERT_EQ(ETIMEDOUT, err); ASSERT_NE(0, nsync_time_cmp(nsync_time_no_deadline, abs_deadline)); } } if (count != limit) { int i = pos + count; if (limit <= i) i -= limit; data[i] = v; if (count == 0) wake = 1; count++; added = 1; } nsync_mu_unlock(&mu); if (wake) nsync_cv_broadcast(&non_empty); return added; } long Get(nsync_time abs_deadline) { long err, v = 0; nsync_mu_lock(&mu); while (!count) { if ((err = nsync_cv_wait_with_deadline(&non_empty, &mu, abs_deadline, 0))) { ASSERT_EQ(ETIMEDOUT, err); ASSERT_NE(0, nsync_time_cmp(nsync_time_no_deadline, abs_deadline)); } } if (count) { v = data[pos]; data[pos] = 0; if (count == limit) { nsync_cv_broadcast(&non_full); } pos++; count--; if (pos == limit) { pos = 0; } } nsync_mu_unlock(&mu); return v; } #define N 10000 void *Producer(void *arg) { for (int i = 0; i < N; i++) { ASSERT_EQ(1, Put((i + 1) * 3, nsync_time_no_deadline)); } return 0; } void *Consumer(void *arg) { for (int i = 0; i < N; i++) { ASSERT_EQ((i + 1) * 3, Get(nsync_time_no_deadline)); } return 0; } TEST(cond, test) { pthread_t t; nsync_mu_init(&mu); limit = 1; ASSERT_EQ(0, pthread_create(&t, 0, Producer, 0)); Consumer(0); ASSERT_EQ(0, pthread_join(t, 0)); limit = 10; ASSERT_EQ(0, pthread_create(&t, 0, Producer, 0)); Consumer(0); ASSERT_EQ(0, pthread_join(t, 0)); limit = 100; ASSERT_EQ(0, pthread_create(&t, 0, Producer, 0)); Consumer(0); ASSERT_EQ(0, pthread_join(t, 0)); limit = 1000; ASSERT_EQ(0, pthread_create(&t, 0, Producer, 0)); Consumer(0); ASSERT_EQ(0, pthread_join(t, 0)); }
4,016
120
jart/cosmopolitan
false
cosmopolitan/test/libc/thread/pthread_attr_setsigmask_np_test.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2023 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/sigset.h" #include "libc/str/str.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" #include "libc/thread/thread2.h" sigset_t actual; sigset_t golden; sigset_t original; static void *MyThread(void *arg) { ASSERT_EQ(0, sigprocmask(SIG_BLOCK, 0, &actual)); ASSERT_EQ(0, memcmp(&golden, &actual, sizeof(sigset_t))); return 0; } TEST(pthread_attr_setsigmask_np, getsAppliedToThread) { pthread_t id; pthread_attr_t attr; sigemptyset(&golden); sigaddset(&golden, SIGSYS); sigaddset(&golden, SIGUSR1); ASSERT_EQ(0, sigprocmask(SIG_BLOCK, 0, &original)); ASSERT_NE(0, memcmp(&golden, &original, sizeof(sigset_t))); ASSERT_EQ(0, pthread_attr_init(&attr)); ASSERT_EQ(0, pthread_attr_setsigmask_np(&attr, &golden)); ASSERT_EQ(0, pthread_create(&id, &attr, MyThread, 0)); ASSERT_EQ(0, pthread_attr_destroy(&attr)); ASSERT_EQ(0, pthread_join(id, 0)); ASSERT_EQ(0, sigprocmask(SIG_BLOCK, 0, &actual)); ASSERT_EQ(0, memcmp(&actual, &original, sizeof(sigset_t))); }
2,903
52
jart/cosmopolitan
false