Remove testonly keyword

This commit is contained in:
Justine Tunney 2022-09-05 08:41:43 -07:00
parent 9be364d40a
commit d721ff8938
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
31 changed files with 78 additions and 94 deletions

View file

@ -602,7 +602,6 @@ typedef struct {
} while (0)
#ifndef __STRICT_ANSI__
#define testonly dontinline _Section(".test")
#define textstartup _Section(".text.startup") noinstrument
#define textexit _Section(".text.exit") noinstrument
#define textreal _Section(".text.real")
@ -610,7 +609,6 @@ typedef struct {
#define textwindows _Section(".text.windows")
#define antiquity _Section(".text.antiquity")
#else
#define testonly
#define textstartup
#define textexit
#define textreal

View file

@ -21,7 +21,7 @@
#define EPSILON 0.00000001L
testonly bool testlib_almostequallongdouble(long double x, long double y) {
bool testlib_almostequallongdouble(long double x, long double y) {
/* TODO(jart): This algorithm has to be binary. */
if (isnan(x) || isnan(y)) return false;
return fabsl(x - y) <= EPSILON;

View file

@ -26,8 +26,7 @@
*
* @see libc/nexgen32e/kCp437.S
*/
testonly bool testlib_binequals(const char16_t *want, const void *got,
size_t n) {
bool testlib_binequals(const char16_t *want, const void *got, size_t n) {
size_t i;
const unsigned char *p = (const unsigned char *)got;
if (!got) return false;

View file

@ -16,8 +16,8 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/safemacros.internal.h"
#include "libc/fmt/fmt.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/mem/mem.h"
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
@ -33,7 +33,7 @@ struct ComboProduct {
struct ComboGroup groups[];
};
mallocesque testonly struct ComboProduct *testlib_setupcomboproduct(
mallocesque struct ComboProduct *testlib_setupcomboproduct(
const struct TestFixture *start, const struct TestFixture *end) {
unsigned i, j, entrycount;
struct ComboProduct *product;
@ -54,8 +54,8 @@ mallocesque testonly struct ComboProduct *testlib_setupcomboproduct(
return product;
}
static testonly void testlib_describecombo(struct ComboProduct *product,
const struct TestFixture *combos) {
static void testlib_describecombo(struct ComboProduct *product,
const struct TestFixture *combos) {
char *p = &g_fixturename[0];
char *pe = p + sizeof(g_fixturename);
for (unsigned i = 0; i < product->n && p < pe; ++i) {
@ -66,10 +66,9 @@ static testonly void testlib_describecombo(struct ComboProduct *product,
}
}
static testonly void testlib_callcombos(struct ComboProduct *product,
const struct TestFixture *combos,
testfn_t *test_start,
testfn_t *test_end) {
static void testlib_callcombos(struct ComboProduct *product,
const struct TestFixture *combos,
testfn_t *test_start, testfn_t *test_end) {
for (;;) {
testlib_describecombo(product, combos);
for (unsigned i = 0; i < product->n; ++i) {
@ -89,9 +88,9 @@ static testonly void testlib_callcombos(struct ComboProduct *product,
* @see ape/ape.lds
* @see libc/testlib/testlib.h
*/
testonly void testlib_runcombos(testfn_t *test_start, testfn_t *test_end,
const struct TestFixture *combo_start,
const struct TestFixture *combo_end) {
void testlib_runcombos(testfn_t *test_start, testfn_t *test_end,
const struct TestFixture *combo_start,
const struct TestFixture *combo_end) {
struct ComboProduct *product;
product = testlib_setupcomboproduct(combo_start, combo_end);
testlib_callcombos(product, combo_start, test_start, test_end);

View file

@ -19,7 +19,7 @@
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
testonly bool testlib_contains(size_t cw, const void *s, const void *needle) {
bool testlib_contains(size_t cw, const void *s, const void *needle) {
if (s == needle) return true;
if (!s || !needle) return false;
return sizeof(cw) == sizeof(char16_t) ? !!strstr16(s, needle)

View file

@ -19,10 +19,10 @@
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
testonly bool testlib_endswith(size_t cw, const void *s, const void *suffix) {
bool testlib_endswith(size_t cw, const void *s, const void *suffix) {
if (s == suffix) return true;
if (!s || !suffix) return false;
return cw == sizeof(wchar_t) ? wcsendswith(s, suffix)
: cw == sizeof(char16_t) ? endswith16(s, suffix)
: endswith(s, suffix);
return cw == sizeof(wchar_t) ? wcsendswith(s, suffix)
: cw == sizeof(char16_t) ? endswith16(s, suffix)
: endswith(s, suffix);
}

View file

@ -21,8 +21,8 @@
#include "libc/sysv/consts/prot.h"
#include "libc/testlib/testlib.h"
testonly int testlib_countfixtures(const struct TestFixture *start,
const struct TestFixture *end) {
int testlib_countfixtures(const struct TestFixture *start,
const struct TestFixture *end) {
return ((intptr_t)end - (intptr_t)start) / sizeof(struct TestFixture);
}
@ -31,9 +31,9 @@ testonly int testlib_countfixtures(const struct TestFixture *start,
* @see ape/ape.lds
* @see libc/testlib/testlib.h
*/
testonly void testlib_runfixtures(testfn_t *test_start, testfn_t *test_end,
const struct TestFixture *fixture_start,
const struct TestFixture *fixture_end) {
void testlib_runfixtures(testfn_t *test_start, testfn_t *test_end,
const struct TestFixture *fixture_start,
const struct TestFixture *fixture_end) {
unsigned i, count;
count = testlib_countfixtures(fixture_start, fixture_end);
for (i = 0; i < count && !g_testlib_failed; ++i) {

View file

@ -20,9 +20,8 @@
#include "libc/testlib/testlib.h"
#include "libc/x/x.h"
testonly void testlib_formatbinaryasglyphs(const char16_t *want,
const void *got, size_t n,
char **out_v1, char **out_v2) {
void testlib_formatbinaryasglyphs(const char16_t *want, const void *got,
size_t n, char **out_v1, char **out_v2) {
if (n == -1ul) n = strlen16(want);
*out_v1 = xasprintf("%`#.*hs", n, want);
*out_v2 = xasprintf(" %`'#.*s", n, got);

View file

@ -21,9 +21,8 @@
#include "libc/testlib/testlib.h"
#include "libc/x/x.h"
testonly void testlib_formatbinaryashex(const char *want, const void *got,
size_t n, char **out_v1,
char **out_v2) {
void testlib_formatbinaryashex(const char *want, const void *got, size_t n,
char **out_v1, char **out_v2) {
size_t i;
uint8_t b;
char *gothex;

View file

@ -22,6 +22,6 @@
#include "libc/x/x.h"
#include "third_party/gdtoa/gdtoa.h"
testonly char *testlib_formatfloat(long double x) {
char *testlib_formatfloat(long double x) {
return xasprintf("%.15Lg", x);
}

View file

@ -16,8 +16,8 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/bits.h"
#include "libc/fmt/fmt.h"
#include "libc/intrin/bits.h"
#include "libc/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/testlib/testlib.h"
@ -25,7 +25,7 @@
static size_t sbufi_;
static char sbufs_[2][256];
dontdiscard testonly char *testlib_formatint(intptr_t x) {
dontdiscard char *testlib_formatint(intptr_t x) {
char *str = sbufi_ < ARRAYLEN(sbufs_) ? sbufs_[sbufi_++] : malloc(256);
char *p = str;
p += sprintf(p, "%ld\t(or %#lx", x, x);

View file

@ -19,6 +19,6 @@
#include "libc/testlib/testlib.h"
#include "libc/x/x.h"
dontdiscard testonly char *testlib_formatrange(intptr_t beg, intptr_t end) {
dontdiscard char *testlib_formatrange(intptr_t beg, intptr_t end) {
return xasprintf("[%#ld,%#ld]", beg, end);
}

View file

@ -25,7 +25,7 @@
/**
* Turns string into code.
*/
dontdiscard testonly char *testlib_formatstr(size_t cw, const void *s, int n) {
dontdiscard char *testlib_formatstr(size_t cw, const void *s, int n) {
if (s) {
switch (cw) {
case 1:

View file

@ -26,7 +26,7 @@
*
* @see unhexstr()
*/
testonly bool testlib_hexequals(const char *want, const void *got, size_t n) {
bool testlib_hexequals(const char *want, const void *got, size_t n) {
size_t i;
const unsigned char *p = (const unsigned char *)got;
if (!got) return false;

View file

@ -28,7 +28,7 @@
* @see libc/testlib/testlib.h
* @see ape/ape.lds
*/
testonly void testlib_runalltests(void) {
void testlib_runalltests(void) {
if ((intptr_t)__testcase_end > (intptr_t)__testcase_start) {
if (testlib_countfixtures(__combo_start, __combo_end)) {
testlib_runcombos(__testcase_start, __testcase_end, __combo_start,

View file

@ -16,12 +16,12 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/atomic.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/errno.h"
#include "libc/fmt/fmt.h"
#include "libc/intrin/atomic.h"
#include "libc/intrin/kprintf.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/log/color.internal.h"
#include "libc/log/internal.h"
#include "libc/log/libfatal.internal.h"
@ -35,9 +35,9 @@ const char *testlib_showerror_isfatal;
const char *testlib_showerror_macro;
const char *testlib_showerror_symbol;
testonly void testlib_showerror(const char *file, int line, const char *func,
const char *method, const char *symbol,
const char *code, char *v1, char *v2) {
void testlib_showerror(const char *file, int line, const char *func,
const char *method, const char *symbol, const char *code,
char *v1, char *v2) {
char *p;
char hostname[128];
__stpcpy(hostname, "unknown");
@ -56,9 +56,9 @@ testonly void testlib_showerror(const char *file, int line, const char *func,
}
/* TODO(jart): Pay off tech debt re duplication */
testonly void testlib_showerror_(int line, const char *wantcode,
const char *gotcode, char *FREED_want,
char *FREED_got, const char *fmt, ...) {
void testlib_showerror_(int line, const char *wantcode, const char *gotcode,
char *FREED_want, char *FREED_got, const char *fmt,
...) {
int e;
va_list va;
char hostname[128];

View file

@ -19,11 +19,10 @@
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
testonly bool testlib_startswith(size_t cw, const void *s, const void *prefix) {
bool testlib_startswith(size_t cw, const void *s, const void *prefix) {
if (s == prefix) return true;
if (!s || !prefix) return false;
return cw == sizeof(wchar_t)
? wcsstartswith(s, prefix)
: cw == sizeof(char16_t) ? startswith16(s, prefix)
: startswith(s, prefix);
return cw == sizeof(wchar_t) ? wcsstartswith(s, prefix)
: cw == sizeof(char16_t) ? startswith16(s, prefix)
: startswith(s, prefix);
}

View file

@ -20,16 +20,15 @@
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
testonly bool testlib_strcaseequals(size_t cw, const void *s1, const void *s2) {
bool testlib_strcaseequals(size_t cw, const void *s1, const void *s2) {
return testlib_strncaseequals(cw, s1, s2, SIZE_MAX);
}
testonly bool testlib_strncaseequals(size_t cw, const void *s1, const void *s2,
size_t n) {
bool testlib_strncaseequals(size_t cw, const void *s1, const void *s2,
size_t n) {
if (s1 == s2) return true;
if (!s1 || !s2) return false;
return (cw == sizeof(wchar_t)
? wcsncasecmp(s1, s2, n)
: cw == sizeof(char16_t) ? strncasecmp16(s1, s2, n)
: strncasecmp(s1, s2, n)) == 0;
return (cw == sizeof(wchar_t) ? wcsncasecmp(s1, s2, n)
: cw == sizeof(char16_t) ? strncasecmp16(s1, s2, n)
: strncasecmp(s1, s2, n)) == 0;
}

View file

@ -20,16 +20,14 @@
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
testonly bool testlib_strequals(size_t cw, const void *s1, const void *s2) {
bool testlib_strequals(size_t cw, const void *s1, const void *s2) {
return testlib_strnequals(cw, s1, s2, SIZE_MAX);
}
testonly bool testlib_strnequals(size_t cw, const void *s1, const void *s2,
size_t n) {
bool testlib_strnequals(size_t cw, const void *s1, const void *s2, size_t n) {
if (s1 == s2) return true;
if (!s1 || !s2) return false;
return (cw == sizeof(wchar_t)
? wcsncmp(s1, s2, n)
: cw == sizeof(char16_t) ? strncmp16(s1, s2, n)
: strncmp(s1, s2, n)) == 0;
return (cw == sizeof(wchar_t) ? wcsncmp(s1, s2, n)
: cw == sizeof(char16_t) ? strncmp16(s1, s2, n)
: strncmp(s1, s2, n)) == 0;
}

View file

@ -72,7 +72,7 @@ COSMOPOLITAN_C_START_
#define __TEST_PROTOTYPE(S, N, A, K) \
void S##_##N(void); \
testfn_t S##_##N##_ptr[] A(S##_##N) = {S##_##N}; \
testonly K void S##_##N(void)
K void S##_##N(void)
#define __TEST_SECTION(NAME, CONTENT) \
".section " NAME "\n" CONTENT "\n\t.previous\n"
@ -89,7 +89,7 @@ COSMOPOLITAN_C_START_
"\t.quad\t" STRINGIFY(GROUP##_##ENTRY)) \
__ROSTR("1:\t.asciz\t" STRINGIFY(#GROUP)) \
__ROSTR("2:\t.asciz\t" STRINGIFY(#ENTRY))); \
testonly void GROUP##_##ENTRY(void)
void GROUP##_##ENTRY(void)
/**
* Enables setup and teardown of test directories.

View file

@ -193,8 +193,7 @@ static void CheckForZombies(void) {
/**
* Runs all test case functions in sorted order.
*/
testonly void testlib_runtestcases(testfn_t *start, testfn_t *end,
testfn_t warmup) {
void testlib_runtestcases(testfn_t *start, testfn_t *end, testfn_t warmup) {
/*
* getpid() calls are inserted to help visually see tests in traces
* which can be performed on Linux, FreeBSD, OpenBSD, and XNU: