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

@ -43,7 +43,6 @@
"forcealignargpointer=",
"noasan=",
"noubsan=",
"testonly=",
"donothing=",
"nosideeffect=",
"unreachable=",,

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:

View File

@ -26,7 +26,7 @@
#include "libc/testlib/ezbench.h"
#include "libc/testlib/testlib.h"
testonly void OnUsr1(int sig) {
void OnUsr1(int sig) {
_exit(0);
}

View File

@ -24,11 +24,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "libc/intrin/pushpop.h"
#include "libc/intrin/safemacros.internal.h"
#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/mem.h"
@ -541,14 +541,14 @@ TEST(sprintf, test_snprintf) {
EXPECT_STREQ("-1", buffer);
}
testonly void vsnprintf_builder_1(char *buf, ...) {
void vsnprintf_builder_1(char *buf, ...) {
va_list args;
va_start(args, buf);
vsnprintf(buf, 100U, "%d", args);
va_end(args);
}
testonly void vsnprintf_builder_3(char *buf, ...) {
void vsnprintf_builder_3(char *buf, ...) {
va_list args;
va_start(args, buf);
vsnprintf(buf, 100U, "%d %d %s", args);

View File

@ -16,8 +16,8 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/mem/critbit0.h"
#include "libc/intrin/bits.h"
#include "libc/mem/critbit0.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
@ -29,25 +29,25 @@ struct Bog {
const char *p[];
};
static testonly dontdiscard struct Bog *NewBog(unsigned n) {
static dontdiscard struct Bog *NewBog(unsigned n) {
struct Bog *res = malloc(sizeof(struct Bog) + sizeof(const char *) * n);
res->i = 0;
res->n = n;
return res;
}
static testonly void ClearBog(struct Bog *bog) {
static void ClearBog(struct Bog *bog) {
bog->i = 0;
}
static testonly void FreeBog(struct Bog **bog) {
static void FreeBog(struct Bog **bog) {
free(*bog), *bog = NULL;
}
static const char *const elems[] = {"a", "aa", "aaz", "abz",
"bba", "bbc", "bbd", NULL};
testonly static void MakeTree(struct critbit0 *tree) {
static void MakeTree(struct critbit0 *tree) {
memset(tree, 0, sizeof(*tree));
for (unsigned i = 0; elems[i]; ++i) {
ASSERT_EQ(true, critbit0_insert(tree, elems[i]));
@ -84,7 +84,7 @@ TEST(critbit0, testDelete) {
critbit0_clear(&tree);
}
static testonly intptr_t allprefixed_cb(const char *elem, void *arg) {
static intptr_t allprefixed_cb(const char *elem, void *arg) {
struct Bog *bog = arg;
ASSERT_LT(bog->i, bog->n);
bog->p[bog->i++] = elem;
@ -110,7 +110,7 @@ TEST(critbit0, testAllPrefixed) {
FreeBog(&a);
}
static testonly intptr_t allprefixed_cb_halt(const char *elem, void *arg) {
static intptr_t allprefixed_cb_halt(const char *elem, void *arg) {
struct Bog *bog = arg;
ASSERT_LT(bog->i, bog->n);
bog->p[bog->i++] = elem;

View File

@ -489,14 +489,14 @@ TEST(wcsncmp, testTwosComplementBane) {
test/libc/str/strcmp_test.c § benchmarks
*/
testonly dontinline int strcmp_pure(const char *a, const char *b) {
dontinline int strcmp_pure(const char *a, const char *b) {
for (; *a == *b; a++, b++) {
if (!*a) break;
}
return (*a & 0xff) - (*b & 0xff);
}
testonly dontinline int strcasecmp_pure(const char *a, const char *b) {
dontinline int strcasecmp_pure(const char *a, const char *b) {
for (; *a && *b; a++, b++) {
if (!(*a == *b || tolower(*a & 0xff) == tolower(*b & 0xff))) {
break;

View File

@ -28,7 +28,7 @@ textstartup static void strftime_test_init(void) {
}
const void *const strftime_test_ctor[] initarray = {strftime_test_init};
testonly char *FormatTime(const char *fmt, struct tm *tm) {
char *FormatTime(const char *fmt, struct tm *tm) {
static char buf[64];
strftime(buf, sizeof(buf), fmt, tm);
return &buf[0];

View File

@ -25,7 +25,7 @@
#include "test/libc/xed/lib.h"
#include "third_party/xed/x86.h"
testonly dontdiscard uint8_t *unbingx86op(const char16_t *codez) {
dontdiscard uint8_t *unbingx86op(const char16_t *codez) {
size_t len;
len = strlen16(codez);
return unbingbuf(xmalloc(ROUNDUP(len, 16)), len, codez, 0x90);
@ -34,7 +34,7 @@ testonly dontdiscard uint8_t *unbingx86op(const char16_t *codez) {
/**
* Long mode instruction length decoder.
*/
testonly int ild(const char16_t *codez) {
int ild(const char16_t *codez) {
int error;
struct XedDecodedInst xedd;
error = xed_instruction_length_decode(
@ -46,7 +46,7 @@ testonly int ild(const char16_t *codez) {
/**
* Real mode instruction length decoder.
*/
testonly int ildreal(const char16_t *codez) {
int ildreal(const char16_t *codez) {
int error;
struct XedDecodedInst xedd;
error = xed_instruction_length_decode(
@ -58,7 +58,7 @@ testonly int ildreal(const char16_t *codez) {
/**
* Legacy mode instruction length decoder.
*/
testonly int ildlegacy(const char16_t *codez) {
int ildlegacy(const char16_t *codez) {
int error;
struct XedDecodedInst xedd;
error = xed_instruction_length_decode(

View File

@ -84,7 +84,6 @@ Keywords={
"offsetof",
"microarchitecture",
"targetclones",
"testonly",
"forcealignargpointer",
"textexit",
"externinline",

View File

@ -26,7 +26,6 @@
"offsetof"
"microarchitecture"
"targetclones"
"testonly"
"forcealignargpointer"
"textexit"
"externinline"

View File

@ -369,7 +369,6 @@ cosmo_kws = frozenset([
"scanfesque",
"strftimeesque",
"strlenesque",
"testonly",
"textexit",
"textreal",
"textstartup",
@ -432,7 +431,6 @@ cosmo_kws = frozenset([
"scanfesque",
"strftimeesque",
"strlenesque",
"testonly",
"textexit",
"textreal",
"textstartup",