mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +00:00
Get Cosmopolitan into releasable state
A new rollup tool now exists for flattening out the headers in a way that works better for our purposes than cpp. A lot of the API clutter has been removed. APIs that aren't a sure thing in terms of general recommendation are now marked internal. There's now a smoke test for the amalgamation archive and gigantic header file. So we can now guarantee you can use this project on the easiest difficulty setting without the gigantic repository. A website is being created, which is currently a work in progress: https://justine.storage.googleapis.com/cosmopolitan/index.html
This commit is contained in:
parent
dba7552c1e
commit
ea0b5d9d1c
775 changed files with 6864 additions and 3963 deletions
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/alg/alg.h"
|
||||
#include "libc/alg/arraylist.h"
|
||||
#include "libc/alg/arraylist.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -61,37 +61,33 @@ TEST(append, isGenericallyTyped) {
|
|||
}
|
||||
|
||||
TEST(concat, worksGreatForStrings) {
|
||||
const char *ks =
|
||||
"Und wird die Welt auch in Flammen stehen\n"
|
||||
"Wir werden wieder auferstehen\n";
|
||||
const char *ks = "Und wird die Welt auch in Flammen stehen\n"
|
||||
"Wir werden wieder auferstehen\n";
|
||||
struct string s;
|
||||
memset(&s, 0, sizeof(s));
|
||||
ASSERT_EQ(0, concat(&s, ks, strlen(ks)));
|
||||
ASSERT_EQ(strlen(ks), concat(&s, ks, strlen(ks) + 1));
|
||||
ASSERT_STREQ(
|
||||
"Und wird die Welt auch in Flammen stehen\n"
|
||||
"Wir werden wieder auferstehen\n"
|
||||
"Und wird die Welt auch in Flammen stehen\n"
|
||||
"Wir werden wieder auferstehen\n",
|
||||
s.p);
|
||||
ASSERT_STREQ("Und wird die Welt auch in Flammen stehen\n"
|
||||
"Wir werden wieder auferstehen\n"
|
||||
"Und wird die Welt auch in Flammen stehen\n"
|
||||
"Wir werden wieder auferstehen\n",
|
||||
s.p);
|
||||
ASSERT_EQ(strlen(ks) * 2 + 1, s.i);
|
||||
free_s(&s.p);
|
||||
}
|
||||
|
||||
TEST(concat, isGenericallyTyped) {
|
||||
const char16_t *ks =
|
||||
u"Drum hoch die Fäuste, hoch zum Licht.\n"
|
||||
u"Unsere schwarzen Seelen bekommt ihr nicht.\n";
|
||||
const char16_t *ks = u"Drum hoch die Fäuste, hoch zum Licht.\n"
|
||||
u"Unsere schwarzen Seelen bekommt ihr nicht.\n";
|
||||
struct string16 s;
|
||||
memset(&s, 0, sizeof(s));
|
||||
ASSERT_EQ(0, concat(&s, ks, strlen16(ks)));
|
||||
ASSERT_EQ(strlen16(ks), concat(&s, ks, strlen16(ks) + 1));
|
||||
ASSERT_STREQ(
|
||||
u"Drum hoch die Fäuste, hoch zum Licht.\n"
|
||||
u"Unsere schwarzen Seelen bekommt ihr nicht.\n"
|
||||
u"Drum hoch die Fäuste, hoch zum Licht.\n"
|
||||
u"Unsere schwarzen Seelen bekommt ihr nicht.\n",
|
||||
s.p);
|
||||
ASSERT_STREQ(u"Drum hoch die Fäuste, hoch zum Licht.\n"
|
||||
u"Unsere schwarzen Seelen bekommt ihr nicht.\n"
|
||||
u"Drum hoch die Fäuste, hoch zum Licht.\n"
|
||||
u"Unsere schwarzen Seelen bekommt ihr nicht.\n",
|
||||
s.p);
|
||||
ASSERT_EQ(strlen16(ks) * 2 + 1, s.i);
|
||||
free_s(&s.p);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/alg/alg.h"
|
||||
#include "libc/alg/bisectcarleft.h"
|
||||
#include "libc/alg/bisectcarleft.internal.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/alg/alg.h"
|
||||
#include "libc/alg/critbit0.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -36,8 +36,14 @@ static testonly nodiscard struct Bog *NewBog(unsigned n) {
|
|||
res->n = n;
|
||||
return res;
|
||||
}
|
||||
static testonly void ClearBog(struct Bog *bog) { bog->i = 0; }
|
||||
static testonly void FreeBog(struct Bog **bog) { free(*bog), *bog = NULL; }
|
||||
|
||||
static testonly void ClearBog(struct Bog *bog) {
|
||||
bog->i = 0;
|
||||
}
|
||||
|
||||
static testonly void FreeBog(struct Bog **bog) {
|
||||
free(*bog), *bog = NULL;
|
||||
}
|
||||
|
||||
static const char *const elems[] = {"a", "aa", "aaz", "abz",
|
||||
"bba", "bbc", "bbd", NULL};
|
||||
|
|
|
@ -42,9 +42,9 @@ TEST(djbsort, test4) {
|
|||
a = memcpy(tgc(tmalloc(n * 4)), kA, n * 4);
|
||||
b = memcpy(tgc(tmalloc(n * 4)), kA, n * 4);
|
||||
c = memcpy(tgc(tmalloc(n * 4)), kA, n * 4);
|
||||
insertionsort(n, a);
|
||||
insertionsort(a, n);
|
||||
djbsort$avx2(b, n);
|
||||
djbsort(n, c);
|
||||
djbsort(c, n);
|
||||
ASSERT_EQ(0, memcmp(a, b, n * 4));
|
||||
ASSERT_EQ(0, memcmp(a, c, n * 4));
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ TEST(djbsort, test64) {
|
|||
a = memcpy(tgc(tmalloc(n * 4)), kA, n * 4);
|
||||
b = memcpy(tgc(tmalloc(n * 4)), kA, n * 4);
|
||||
c = memcpy(tgc(tmalloc(n * 4)), kA, n * 4);
|
||||
insertionsort(n, a);
|
||||
djbsort(n, c);
|
||||
insertionsort(a, n);
|
||||
djbsort(c, n);
|
||||
ASSERT_EQ(0, memcmp(a, c, n * 4));
|
||||
if (X86_HAVE(AVX2)) {
|
||||
djbsort$avx2(b, n);
|
||||
|
@ -82,6 +82,6 @@ BENCH(djbsort, bench) {
|
|||
n = 256;
|
||||
a = gc(memalign(32, n * 4));
|
||||
EZBENCH2("insertionsort[255]", rngset(a, n * 4, rand64, -1),
|
||||
insertionsort(n, a));
|
||||
EZBENCH2("djbsort[255]", rngset(a, n * 4, rand64, -1), djbsort(n, a));
|
||||
insertionsort(a, n));
|
||||
EZBENCH2("djbsort[255]", rngset(a, n * 4, rand64, -1), djbsort(a, n));
|
||||
}
|
||||
|
|
|
@ -20,19 +20,19 @@
|
|||
|
||||
TEST(REPLACESTR, demo) {
|
||||
EXPECT_STREQ(S("hello friends"),
|
||||
replacestr(S("hello world"), S("world"), S("friends")));
|
||||
EXPECT_STREQ(S("bbbbbbbb"), replacestr(S("aaaa"), S("a"), S("bb")));
|
||||
REPLACESTR(S("hello world"), S("world"), S("friends")));
|
||||
EXPECT_STREQ(S("bbbbbbbb"), REPLACESTR(S("aaaa"), S("a"), S("bb")));
|
||||
}
|
||||
|
||||
TEST(REPLACESTR, emptyString) {
|
||||
EXPECT_STREQ(S(""), replacestr(S(""), S("x"), S("y")));
|
||||
EXPECT_STREQ(S(""), REPLACESTR(S(""), S("x"), S("y")));
|
||||
}
|
||||
|
||||
TEST(REPLACESTR, emptyNeedle) {
|
||||
EXPECT_EQ(NULL, replacestr(S("a"), S(""), S("a")));
|
||||
EXPECT_EQ(NULL, REPLACESTR(S("a"), S(""), S("a")));
|
||||
EXPECT_EQ(EINVAL, errno);
|
||||
}
|
||||
|
||||
TEST(REPLACESTR, needleInReplacement_doesntExplode) {
|
||||
EXPECT_STREQ(S("xxxxxxx"), replacestr(S("x"), S("x"), S("xxxxxxx")));
|
||||
EXPECT_STREQ(S("xxxxxxx"), REPLACESTR(S("x"), S("x"), S("xxxxxxx")));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,10 @@ TEST(bitreverse, test) {
|
|||
EXPECT_EQ(0xde00, (bitreverse16)(123));
|
||||
EXPECT_EQ(0xde000000u, bitreverse32(123));
|
||||
EXPECT_EQ(0xde000000u, (bitreverse32)(123));
|
||||
EXPECT_EQ(0xde00000000000000ul, bitreverse64(123));
|
||||
EXPECT_EQ(0xde00000000000000ul, (bitreverse64)(123));
|
||||
EXPECT_EQ(0x482d96c305f7c697ul, bitreverse64(0xe963efa0c369b412));
|
||||
EXPECT_EQ(0x482d96c305f7c697ul, (bitreverse64)(0xe963efa0c369b412));
|
||||
}
|
||||
|
||||
BENCH(bitreverse, bench) {
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
TEST(bt_uint16x4, test) {
|
||||
uint16_t v[4] = {0};
|
||||
EXPECT_FALSE(bt(v, 0));
|
||||
EXPECT_FALSE(bt(v, 63));
|
||||
EXPECT_FALSE(bts(v, 63));
|
||||
EXPECT_TRUE(bt(v, 63));
|
||||
EXPECT_TRUE(bts(v, 63));
|
||||
}
|
||||
|
||||
TEST(bt_uint32x2, test) {
|
||||
uint32_t v[2] = {0};
|
||||
EXPECT_FALSE(bt(v, 0));
|
||||
EXPECT_FALSE(bt(v, 63));
|
||||
EXPECT_FALSE(bts(v, 63));
|
||||
EXPECT_TRUE(bt(v, 63));
|
||||
EXPECT_TRUE(bts(v, 63));
|
||||
}
|
||||
|
||||
TEST(bt_uint64x1, test) {
|
||||
uint64_t v = 0;
|
||||
EXPECT_FALSE(bt(&v, 0));
|
||||
EXPECT_FALSE(bt(&v, 63));
|
||||
EXPECT_FALSE(bts(&v, 63));
|
||||
EXPECT_TRUE(bt(&v, 63));
|
||||
EXPECT_TRUE(bts(&v, 63));
|
||||
}
|
||||
|
||||
TEST(bt_uint64, testPresent) {
|
||||
uint64_t v = 1;
|
||||
EXPECT_TRUE(bt(&v, 0));
|
||||
EXPECT_FALSE(bt(&v, 63));
|
||||
v = 0x8000000000000001;
|
||||
EXPECT_TRUE(bt(&v, 0));
|
||||
EXPECT_TRUE(bt(&v, 63));
|
||||
}
|
||||
|
||||
TEST(bt_uint64, testPresent_avoidingDeadCodeElimination) {
|
||||
volatile uint64_t v = 1;
|
||||
EXPECT_TRUE(bt(&v, 0));
|
||||
EXPECT_FALSE(bt(&v, 63));
|
||||
v = 0x8000000000000001;
|
||||
EXPECT_TRUE(bt(&v, 0));
|
||||
EXPECT_TRUE(bt(&v, 63));
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#include "libc/macros.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
#define ROR(w, k) (CheckUnsigned(w) >> (k) | (w) << (sizeof(w) * 8 - (k)))
|
||||
#define ROL(w, k) ((w) << (k) | CheckUnsigned(w) >> (sizeof(w) * 8 - (k)))
|
||||
|
||||
TEST(TwosComplementBane, LiteralsThatAreLiterallyTheSameNumber) {
|
||||
EXPECT_EQ(4, sizeof(INT_MIN));
|
||||
EXPECT_EQ(8, sizeof(-2147483648));
|
||||
|
@ -30,12 +33,6 @@ TEST(TwosComplementBane, LiteralsThatAreLiterallyTheSameNumber) {
|
|||
EXPECT_FALSE(TYPE_SIGNED(-0x80000000));
|
||||
}
|
||||
|
||||
TEST(ShiftArithmeticRight, DeclassifiedByGuySteele) {
|
||||
EXPECT_EQ(-1u, SAR(-2u, 1u));
|
||||
EXPECT_EQ(-1u, SAR(-1u, 1u));
|
||||
EXPECT_EQ(0xc0000000u, SAR(0x80000000u, 1u));
|
||||
}
|
||||
|
||||
TEST(RotateRight, Test) {
|
||||
EXPECT_EQ(0x41122334u, ROR(0x11223344u, 4));
|
||||
EXPECT_EQ(0x44112233u, ROR(0x11223344u, 8));
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
TEST(unsignedsubtract, testMacro) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/dce.h"
|
||||
|
|
|
@ -24,11 +24,13 @@
|
|||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
testonly void OnCtrlC(int sig) { _exit(0); }
|
||||
testonly void OnCtrlC(int sig) {
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
TEST(signal, test) {
|
||||
if (IsWindows()) return; /* omg */
|
||||
ASSERT_NE(SIG_ERR, signal(SIGINT, OnCtrlC));
|
||||
ASSERT_NE(-1, raise(SIGINT));
|
||||
die();
|
||||
__die();
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*-*- 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 │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/dos.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
TEST(DosDateTimeToUnix, test) {
|
||||
EXPECT_EQ(1601929396,
|
||||
DosDateTimeToUnix(DOS_DATE(2020, 10, 5), DOS_TIME(20, 23, 16)));
|
||||
}
|
||||
|
||||
TEST(DosDateTimeToUnix, testNotLeapYear) {
|
||||
EXPECT_EQ(4107529396,
|
||||
DosDateTimeToUnix(DOS_DATE(2100, 2, 28), DOS_TIME(20, 23, 16)));
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/crypto/rijndael.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/bing.h"
|
||||
#include "libc/fmt/bing.internal.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
│ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN │
|
||||
│ THE SOFTWARE. │
|
||||
└─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/bits/pushpop.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/conv/itoa.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/intrin/mpsadbw.h"
|
||||
#include "libc/intrin/pabsb.h"
|
||||
#include "libc/intrin/pabsd.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/intrin/palignr.h"
|
||||
#include "libc/rand/rand.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/macros.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/nexgen32e/kompressor.h"
|
||||
|
@ -73,8 +73,8 @@ TEST(lz4, decompress_runLengthDecode) {
|
|||
TEST(lz4, zoneFileGmt) {
|
||||
if (!fileexists("usr/share/zoneinfo.dict.lz4")) return;
|
||||
struct MappedFile dict, gmt;
|
||||
CHECK_NE(-1, mapfileread("usr/share/zoneinfo.dict.lz4", &dict));
|
||||
CHECK_NE(-1, mapfileread("usr/share/zoneinfo/GMT.lz4", &gmt));
|
||||
CHECK_NE(-1, MapFileRead("usr/share/zoneinfo.dict.lz4", &dict));
|
||||
CHECK_NE(-1, MapFileRead("usr/share/zoneinfo/GMT.lz4", &gmt));
|
||||
size_t mapsize, gmtsize;
|
||||
char *mapping, *gmtdata;
|
||||
lz4decode((gmtdata = lz4decode(
|
||||
|
@ -91,6 +91,6 @@ TEST(lz4, zoneFileGmt) {
|
|||
u" ☺ ☺ ☺ ☺ ♦° GMT ◙GMT0◙",
|
||||
gmtdata);
|
||||
munmap(mapping, mapsize);
|
||||
unmapfile(&dict);
|
||||
unmapfile(&gmt);
|
||||
UnmapFile(&dict);
|
||||
UnmapFile(&gmt);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
|
|
7
test/libc/release/smoke.c
Normal file
7
test/libc/release/smoke.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
int main() {
|
||||
FILE *f;
|
||||
f = fopen("/dev/null", "w");
|
||||
fprintf(f, "hello world\n");
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
38
test/libc/release/test.mk
Normal file
38
test/libc/release/test.mk
Normal file
|
@ -0,0 +1,38 @@
|
|||
#-*-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───────────────────────┘
|
||||
|
||||
o/$(MODE)/test/libc/release/cosmopolitan.zip: \
|
||||
o/cosmopolitan.h \
|
||||
o/$(MODE)/ape/ape.lds \
|
||||
o/$(MODE)/libc/crt/crt.o \
|
||||
o/$(MODE)/ape/ape.o \
|
||||
o/$(MODE)/cosmopolitan.a
|
||||
zip -j $@ $^
|
||||
|
||||
o/$(MODE)/test/libc/release/smoke.com: \
|
||||
test/libc/release/smoke.c \
|
||||
o/cosmopolitan.h \
|
||||
o/$(MODE)/ape/ape.lds \
|
||||
o/$(MODE)/libc/crt/crt.o \
|
||||
o/$(MODE)/ape/ape.o \
|
||||
o/$(MODE)/cosmopolitan.a
|
||||
@ACTION=CC build/compile $(CC) \
|
||||
-o $@ \
|
||||
-Os \
|
||||
-static \
|
||||
-fno-pie \
|
||||
-no-pie \
|
||||
-nostdlib \
|
||||
-nostdinc \
|
||||
-Wl,--oformat=binary \
|
||||
-Wl,-T,o/$(MODE)/ape/ape.lds \
|
||||
-include o/cosmopolitan.h \
|
||||
test/libc/release/smoke.c \
|
||||
o/$(MODE)/libc/crt/crt.o \
|
||||
o/$(MODE)/ape/ape.o \
|
||||
o/$(MODE)/cosmopolitan.a
|
||||
|
||||
.PHONY: o/$(MODE)/test/libc/release
|
||||
o/$(MODE)/test/libc/release: \
|
||||
o/$(MODE)/test/libc/release/smoke.com \
|
||||
o/$(MODE)/test/libc/release/smoke.com.runs
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/getdosenviron.h"
|
||||
#include "libc/runtime/getdosenviron.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
TEST(grow, testNull_hasAllocatingBehavior) {
|
||||
void *p = NULL;
|
||||
size_t capacity = 0;
|
||||
EXPECT_TRUE(grow(&p, &capacity, 1, 0));
|
||||
EXPECT_TRUE(__grow(&p, &capacity, 1, 0));
|
||||
EXPECT_NE(NULL, p);
|
||||
EXPECT_EQ(32, capacity);
|
||||
free_s(&p);
|
||||
|
@ -37,7 +37,7 @@ TEST(grow, testNull_hasAllocatingBehavior) {
|
|||
TEST(grow, testCapacity_isInUnits_withTerminatorGuarantee) {
|
||||
void *p = NULL;
|
||||
size_t capacity = 0;
|
||||
EXPECT_TRUE(grow(&p, &capacity, 8, 0));
|
||||
EXPECT_TRUE(__grow(&p, &capacity, 8, 0));
|
||||
EXPECT_NE(NULL, p);
|
||||
EXPECT_EQ(32 / 8 + 1, capacity);
|
||||
free_s(&p);
|
||||
|
@ -48,7 +48,7 @@ TEST(grow, testStackMemory_convertsToDynamic) {
|
|||
int *p = A;
|
||||
size_t capacity = ARRAYLEN(A);
|
||||
if (!isheap(p)) {
|
||||
EXPECT_TRUE(grow(&p, &capacity, sizeof(int), 0));
|
||||
EXPECT_TRUE(__grow(&p, &capacity, sizeof(int), 0));
|
||||
EXPECT_TRUE(isheap(p));
|
||||
EXPECT_GT(capacity, ARRAYLEN(A));
|
||||
EXPECT_EQ(1, p[0]);
|
||||
|
@ -64,7 +64,7 @@ TEST(grow, testGrowth_clearsNewMemory) {
|
|||
size_t i, capacity = 123;
|
||||
char *p = malloc(capacity);
|
||||
memset(p, 'a', capacity);
|
||||
EXPECT_TRUE(grow(&p, &capacity, 1, 0));
|
||||
EXPECT_TRUE(__grow(&p, &capacity, 1, 0));
|
||||
EXPECT_GT(capacity, 123);
|
||||
for (i = 0; i < 123; ++i) ASSERT_EQ('a', p[i]);
|
||||
for (i = 123; i < capacity; ++i) ASSERT_EQ(0, p[i]);
|
||||
|
@ -74,11 +74,11 @@ TEST(grow, testGrowth_clearsNewMemory) {
|
|||
TEST(grow, testBonusParam_willGoAboveAndBeyond) {
|
||||
size_t capacity = 32;
|
||||
char *p = malloc(capacity);
|
||||
EXPECT_TRUE(grow(&p, &capacity, 1, 0));
|
||||
EXPECT_TRUE(__grow(&p, &capacity, 1, 0));
|
||||
EXPECT_LT(capacity, 1024);
|
||||
free_s(&p);
|
||||
p = malloc((capacity = 32));
|
||||
EXPECT_TRUE(grow(&p, &capacity, 1, 1024));
|
||||
EXPECT_TRUE(__grow(&p, &capacity, 1, 1024));
|
||||
EXPECT_GT(capacity, 1024);
|
||||
free_s(&p);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ TEST(grow, testOverflow_returnsFalseAndDoesNotFree) {
|
|||
int *p = A;
|
||||
size_t capacity = ARRAYLEN(A);
|
||||
if (!isheap(p)) {
|
||||
EXPECT_FALSE(grow(&p, &capacity, pushpop(SIZE_MAX), 0));
|
||||
EXPECT_FALSE(__grow(&p, &capacity, pushpop(SIZE_MAX), 0));
|
||||
EXPECT_FALSE(isheap(p));
|
||||
EXPECT_EQ(capacity, ARRAYLEN(A));
|
||||
EXPECT_EQ(1, p[0]);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/runtime/memtrack.h"
|
||||
#include "libc/runtime/missioncritical.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/inaddr.h"
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/str/oldutf16.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpdecode.h"
|
||||
#include "libc/str/tpdecode.internal.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
TEST(getutf16, testNul) {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tinymemccpy.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/str/oldutf16.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/unicode/unicode.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/sha256.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/hyperion.h"
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
sigset_t ss;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nexgen32e/cachesize.h"
|
||||
#include "libc/nexgen32e/tinystrcmp.h"
|
||||
#include "libc/nexgen32e/tinystrcmp.internal.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/rand/rand.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nexgen32e/tinystrlen.h"
|
||||
#include "libc/nexgen32e/tinystrlen.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/bing.h"
|
||||
#include "libc/fmt/bing.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpdecode.h"
|
||||
#include "libc/str/tpdecode.internal.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
wint_t wc;
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/progn.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpencode.h"
|
||||
#include "libc/str/tpencode.internal.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
char buf[8];
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "libc/runtime/gc.h"
|
||||
#include "libc/runtime/rbx.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/undeflate.h"
|
||||
|
|
|
@ -15,6 +15,7 @@ o/$(MODE)/test/libc: \
|
|||
o/$(MODE)/test/libc/mem \
|
||||
o/$(MODE)/test/libc/nexgen32e \
|
||||
o/$(MODE)/test/libc/rand \
|
||||
o/$(MODE)/test/libc/release \
|
||||
o/$(MODE)/test/libc/runtime \
|
||||
o/$(MODE)/test/libc/sock \
|
||||
o/$(MODE)/test/libc/stdio \
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/bing.h"
|
||||
#include "libc/fmt/bing.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/str/str.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue