Add syscalls to Blinkenlights and fix bugs

This commit is contained in:
Justine Tunney 2022-05-13 13:31:21 -07:00
parent f6df29cc3d
commit 578cb21591
25 changed files with 187 additions and 108 deletions

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/stat.h"
#include "libc/dce.h"
@ -33,7 +34,9 @@ const char *path;
TEST(ftruncate, test) {
mkdir("o", 0755);
mkdir("o/tmp", 0755);
path = gc(xasprintf("o/tmp/%s.%d", program_invocation_short_name, getpid()));
path = gc(xasprintf("o/tmp/%s.%d",
firstnonnull(program_invocation_short_name, "unknown"),
getpid()));
ASSERT_NE(-1, (fd = creat(path, 0755)));
ASSERT_EQ(5, write(fd, "hello", 5));
errno = 31337;

View file

@ -98,7 +98,7 @@ TEST(setrlimit, testFileSizeLimit) {
ASSERT_EQ(0, setrlimit(RLIMIT_FSIZE, &rlim));
snprintf(tmpname, sizeof(tmpname), "%s/%s.%d",
firstnonnull(getenv("TMPDIR"), "/tmp"),
program_invocation_short_name, getpid());
firstnonnull(program_invocation_short_name, "unknown"), getpid());
ASSERT_NE(-1, (fd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC)));
rngset(junkdata, 512, rand64, -1);
for (i = 0; i < 5 * 1024 * 1024 / 512; ++i) {

View file

@ -20,7 +20,7 @@
#include "libc/testlib/testlib.h"
TEST(strsignal, test) {
EXPECT_STREQ("SIGUNKNOWN", strsignal(0));
EXPECT_STREQ("SIGZERO", strsignal(0));
EXPECT_STREQ("SIGINT", strsignal(SIGINT));
EXPECT_STREQ("SIGQUIT", strsignal(SIGQUIT));
EXPECT_STREQ("SIGALRM", strsignal(SIGALRM));