0.3.0: converge relibc to upstream 0.6.0 + Red Bear patches

This commit is contained in:
2026-07-06 19:13:08 +03:00
parent 1a0edd8eeb
commit 4ef7e57571
1466 changed files with 75236 additions and 13644 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
/bins_static/
/bins_dynamic/
/build_*/
/bins_*/
/gen/
/*.out
+5
View File
@@ -0,0 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "relibc-tests"
version = "0.1.0"
+9
View File
@@ -0,0 +1,9 @@
[package]
name = "relibc-tests"
version = "0.1.0"
authors = ["Jeremy Soller <jeremy@system76.com>"]
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
+154 -220
View File
@@ -1,249 +1,183 @@
# Binaries that should generate the same output every time
EXPECT_NAMES=\
alloca \
args \
arpainet \
assert \
constructor \
ctype \
dirent/scandir \
errno \
error \
fcntl/create \
fcntl/fcntl \
fnmatch \
libgen \
locale \
math \
netdb/getaddrinfo \
ptrace \
regex \
select \
setjmp \
sigaction \
signal \
stdio/fputs \
stdio/fread \
stdio/fseek \
stdio/fwrite \
stdio/mutex \
stdio/popen \
stdio/printf \
stdio/rename \
stdio/scanf \
stdio/sprintf \
stdio/printf_space_pad \
stdio/ungetc_ftell \
stdio/fscanf_offby1 \
stdio/fscanf \
stdio/printf_neg_pad \
stdlib/a64l \
stdlib/alloc \
stdlib/atof \
stdlib/atoi \
stdlib/div \
stdlib/env \
stdlib/mkostemps \
stdlib/rand \
stdlib/rand48 \
stdlib/random \
stdlib/strtod \
stdlib/strtol \
stdlib/strtoul \
stdlib/system \
string/mem \
string/strcat \
string/strchr \
string/strcpy \
string/strcspn \
string/strlen \
string/strncmp \
string/strpbrk \
string/strrchr \
string/strspn \
string/strstr \
string/strtok \
string/strtok_r \
string/strsignal \
strings \
sys_mman \
time/asctime \
time/gmtime \
time/macros \
time/mktime \
time/strftime \
time/time \
tls \
unistd/access \
unistd/brk \
unistd/dup \
unistd/exec \
unistd/fchdir \
unistd/fork \
unistd/fsync \
unistd/ftruncate \
unistd/pipe \
unistd/rmdir \
unistd/sleep \
unistd/swab \
unistd/write \
waitpid \
wchar/fwide \
wchar/mbrtowc \
wchar/mbsrtowcs \
wchar/printf-on-wchars \
wchar/putwchar \
wchar/wcrtomb \
wchar/wcscspn \
wchar/wcsrchr \
wchar/wcsstr \
wchar/wcstod \
wchar/wcstol \
wchar/wcscasecmp \
wchar/wcsncasecmp \
# TODO: Fix these
# mkfifo
# netdb/netdb \
include ../config.mk
# issues with linking stdin, stdout, stderr
STATIC_ONLY_NAMES=\
futimens \
stdio/all \
stdio/buffer \
stdio/fgets \
stdio/freopen \
stdio/getc_unget \
stdio/setvbuf \
stdio/ungetc_multiple \
time/localtime \
wchar/wcstok \
wctype/towlower \
wctype/towupper \
# need to call fini in ld_so's _start
STATIC_ONLY_NAMES+=\
destructor \
# issues with linking optarg, optind etc.
STATIC_ONLY_NAMES+=\
unistd/getopt \
unistd/getopt_long \
IS_REDOX?=0
IS_STATIC?=0
BUILD?=./build_$(TARGET)
DYNAMIC_ONLY_NAMES=\
dlfcn
include ./Makefile.tests.mk
# Binaries that may generate varied output
NAMES=\
$(EXPECT_NAMES) \
dirent/main \
pwd \
stdio/tempnam \
stdio/tmpnam \
stdlib/bsearch \
stdlib/mktemp \
stdlib/realpath \
sys_epoll/epoll \
sys_utsname/uname \
time/gettimeofday \
unistd/chdir \
unistd/getcwd \
unistd/gethostname \
unistd/getid \
unistd/getpagesize \
unistd/isatty \
unistd/link \
unistd/pathconf \
unistd/setid \
unistd/stat \
unistd/sysconf
# resource/getrusage
# time/times
BINS=$(patsubst %,bins_static/%,$(NAMES))
BINS+=$(patsubst %,bins_static/%,$(STATIC_ONLY_NAMES))
BINS+=$(patsubst %,bins_dynamic/%,$(NAMES))
BINS+=$(patsubst %,bins_dynamic/%,$(DYNAMIC_ONLY_NAMES))
EXPECT_BINS=$(patsubst %,bins_static/%,$(EXPECT_NAMES))
EXPECT_BINS+=$(patsubst %,bins_static/%,$(STATIC_ONLY_NAMES))
EXPECT_BINS+=$(patsubst %,bins_dynamic/%,$(EXPECT_NAMES))
EXPECT_BINS+=$(patsubst %,bins_dynamic/%,$(DYNAMIC_ONLY_NAMES))
TEST_RUNNER?=sh --
CARGO_TEST?=cargo
TEST_RUNNER?=
.PHONY: all clean run expected verify
all: $(BINS)
all: build
clean:
rm -rf bins_* gen *.out
rm -rf $(BUILD)/bins_* $(BUILD)/gen $(BUILD)/target
run: | $(BINS)
for bin in $(BINS); \
do \
echo "# $${bin} #"; \
"$${bin}" test args || exit $$?; \
done
build: $(BUILD)/bins_verify/relibc-tests $(BINS) $(EXPECT_BINS) $(EXPECT_INPUT_BINS) support_build
expected: | $(EXPECT_BINS)
rm -rf expected
mkdir -p expected
for bin in $(EXPECT_BINS); \
do \
echo "# $${bin} #"; \
mkdir -p expected/`dirname $${bin}`; \
"$${bin}" test args > "expected/$${bin}.stdout" 2> "expected/$${bin}.stderr" || exit $$?; \
done
support_build: $(BUILD)/expected \
$(BUILD)/Makefile \
$(BUILD)/Makefile.tests.mk \
$(BUILD)/example_dir \
$(BUILD)/select.c \
$(BUILD)/stdlib/realpath.c \
$(BUILD)/stdio/fread.in \
$(BUILD)/stdio/fscanf_offby1.c \
$(BUILD)/stdio/fscanf.c \
$(BUILD)/stdio/stdio.in \
$(BUILD)/stdio/getline.in \
$(BUILD)/stdio/ungetc_ftell.c \
$(BUILD)/sys_stat/stat.c \
$(BUILD)/unistd/link.c \
$(BUILD)/wchar/fgetwc.in \
$(BUILD)/wchar/ungetwc.in
verify: | $(EXPECT_BINS)
$(TEST_RUNNER) ./verify.sh $(EXPECT_BINS)
run: build
$(MAKE) run -C $(BUILD)
run-once: $(BUILD)/bins_verify/relibc-tests $(BUILD)/$(TESTBIN) support_build
$(MAKE) run-once -C $(BUILD) TESTBIN=$(TESTBIN)
$(BUILD)/bins_verify/relibc-tests: src/main.rs
mkdir -p $(BUILD)/bins_verify
$(CARGO_TEST) build --release --bin relibc-tests --artifact-dir $(BUILD)/bins_verify --target-dir $(BUILD)/target -Z unstable-options
rm -rf $(BUILD)/target
$(BUILD)/Makefile: Makefile.run.mk
cp -a $< "$@"
$(BUILD)/Makefile.tests.mk: Makefile.tests.mk
cp -a $< "$@"
$(BUILD)/expected: expected
rm -rf "$@"
cp -a "$<" $(BUILD)/
$(BUILD)/example_dir: example_dir
rm -rf "$@"
cp -a "$<" $(BUILD)/
$(BUILD)/%.in: %.in
@mkdir -p "$$(dirname "$@")"
cp "$*.in" "$@"
$(BUILD)/%.c: %.c
@mkdir -p "$$(dirname "$@")"
cp "$*.c" "$@"
FLAGS=\
-std=c11 \
-fno-builtin \
-fno-stack-protector \
-Wall \
-Wextra \
-Werror \
-Wno-deprecated-declarations \
-pedantic \
-g \
-I .
STATIC_FLAGS=\
../sysroot/lib/libc.a \
-static
NATIVE_RELIBC?=0
ifeq ($(NATIVE_RELIBC),0)
DYNAMIC_FLAGS=\
-Wl,--enable-new-dtags \
-Wl,-export-dynamic
SYSROOT?=$(abspath ../sysroot/$(TARGET)/)
SYSROOT_TARGET?=$(SYSROOT)
$(SYSROOT):
$(MAKE) -C .. sysroot
NATIVE_LIBC?=0
ifeq ($(NATIVE_LIBC),0)
FLAGS+=\
-nostdinc \
-nostdlib \
-isystem ../sysroot/include \
../sysroot/lib/crt0.o \
../sysroot/lib/crti.o \
../sysroot/lib/crtn.o
-isystem $(SYSROOT)/include \
$(SYSROOT)/lib/crt0.o \
$(SYSROOT)/lib/crti.o \
$(SYSROOT)/lib/crtn.o
../sysroot:
$(MAKE) -C .. sysroot
bins_static/%: %.c ../sysroot
mkdir -p "$$(dirname "$@")"
$(CC) "$<" -o "$@" $(FLAGS) $(STATIC_FLAGS)
SYSROOT_LIB=$(shell realpath ../sysroot/lib/)
DYNAMIC_FLAGS=\
-Wl,-dynamic-linker=$(SYSROOT_LIB)/ld64.so.1 \
-Wl,--enable-new-dtags \
-Wl,-rpath=$(SYSROOT_LIB) \
-Wl,-export-dynamic \
-L $(SYSROOT_LIB) \
-lc
bins_dynamic/%: %.c ../sysroot
mkdir -p "$$(dirname "$@")"
$(CC) "$<" -o "$@" $(FLAGS) $(DYNAMIC_FLAGS)
else
bins_static/%: %.c
mkdir -p "$$(dirname "$@")"
$(CC) "$<" -o "$@" $(FLAGS) $(STATIC_FLAGS)
bins_dynamic/%: %.c
mkdir -p "$$(dirname "$@")"
$(CC) "$<" -o "$@" $(FLAGS)
ifeq ($(TARGET),aarch64-unknown-redox)
FLAGS+=-mno-outline-atomics
endif
STATIC_FLAGS+=\
$(SYSROOT)/lib/libc.a
ifeq ($(IS_REDOX),0)
DYNAMIC_FLAGS+=\
-Wl,-dynamic-linker=$(SYSROOT_TARGET)/$(LD_SO_PATH) \
-Wl,-rpath=$(SYSROOT_TARGET)/lib:\$$ORIGIN \
-L $(SYSROOT)/lib \
-lc \
-fpic
else
# TODO: Make -dynamic-linker works
DYNAMIC_FLAGS+=\
-Wl,-rpath=$(SYSROOT_TARGET)/lib:\$$ORIGIN \
-L $(SYSROOT)/lib \
-lc \
-fpic
endif
DEPS=../sysroot/$(TARGET)
else # ifeq ($(NATIVE_LIBC),1)
DYNAMIC_FLAGS+=\
-Wl,-rpath=\$$ORIGIN
ifeq ($(IS_REDOX),0)
# glibc
FLAGS+=\
-D_POSIX_C_SOURCE=200809L \
-D_DEFAULT_SOURCE \
-D_XOPEN_SOURCE=700 \
-D_GNU_SOURCE \
-lcrypt \
-lm
else
# hosted redox, no extra options needed
endif
endif
$(BUILD)/bins_static/%: %.c $(DEPS)
mkdir -p "$$(dirname "$@")"
@$(CC) "$<" -o "$@" $(FLAGS) $(STATIC_FLAGS)
$(BUILD)/bins_expect_input/%: %.c %.exp $(DEPS)
mkdir -p "$$(dirname "$@")"
@$(CC) "$<" -o "$@" $(FLAGS) $(STATIC_FLAGS)
cp "$*.exp" $(addsuffix .exp,"$@")
$(BUILD)/bins_dynamic/%.so: %.c $(DEPS)
mkdir -p "$$(dirname "$@")"
@$(CC) "$<" -o "$@" -shared -fpic $(FLAGS) $(DYNAMIC_FLAGS)
# foobar depends on foo
$(BUILD)/bins_dynamic/libfoobar.so: libfoobar.c $(BUILD)/bins_dynamic/libfoo.so $(DEPS)
mkdir -p "$$(dirname "$@")"
@$(CC) "$<" -o "$@" -shared -fpic $(FLAGS) $(DYNAMIC_FLAGS) -L $(BUILD)/bins_dynamic -lfoo
$(BUILD)/bins_dynamic/dlfcn: dlfcn.c $(BUILD)/bins_dynamic/sharedlib.so $(DEPS)
mkdir -p "$$(dirname "$@")"
@$(CC) "$<" -o "$@" $(FLAGS) $(DYNAMIC_FLAGS)
$(BUILD)/bins_dynamic/dlopen_scopes: dlopen_scopes.c $(BUILD)/bins_dynamic/libfoobar.so $(BUILD)/bins_dynamic/libfoo.so $(DEPS)
mkdir -p "$$(dirname "$@")"
@$(CC) "$<" -o "$@" $(FLAGS) $(DYNAMIC_FLAGS)
$(BUILD)/bins_dynamic/%: %.c $(DEPS)
mkdir -p "$$(dirname "$@")"
@$(CC) "$<" -o "$@" $(FLAGS) $(DYNAMIC_FLAGS)
$(BUILD)/gen/includes: includes.c $(DEPS)
rm -rf $@.tmp $@
mkdir -p $@.tmp
@$(CC) "$<" -H $(FLAGS) $(DYNAMIC_FLAGS) 2> $@.tmp/graph.txt
sed -i 's|$(SYSROOT)/include/||g' $@.tmp/graph.txt
mv $@.tmp $@
+33
View File
@@ -0,0 +1,33 @@
BUILD?=.
ifeq ($(shell uname),Redox)
IS_REDOX=1
else
IS_REDOX=0
endif
include ./Makefile.tests.mk
CARGO_TEST?=cargo
TEST_RUNNER?=
.PHONY: all clean run run-once
all: run
clean:
rm -rf $(BUILD)/gen
run: $(BUILD)/bins_verify/relibc-tests $(BINS) $(EXPECT_BINS) $(EXPECT_INPUT_BINS)
@echo "\033[1;36;49mRunning tests\033[0m"
$(TEST_RUNNER) $< $(patsubst %,-s%,$(BINS)) $(EXPECT_BINS)
for exp in $(EXPECT_INPUT_BINS); \
do \
echo "# expect $$(readlink -e $${exp}.exp) $$(readlink -e $${exp}) #"; \
expect "$$(readlink -e $${exp}.exp)" "$$(readlink -e $${exp})" test args || exit $$?; \
done
run-once: $(BUILD)/bins_verify/relibc-tests $(BUILD)/$(TESTBIN)
@echo "\033[1;36;49mRunning single test $(TESTBIN) $*\033[0m"
@if [ -f "expected/$(TESTBIN).stdout" ]; then \
$(TEST_RUNNER) $< $(BUILD)/$(TESTBIN); \
else $(TEST_RUNNER) $< -s$(BUILD)/$(TESTBIN); fi
+358
View File
@@ -0,0 +1,358 @@
# If compiling for Redox, IS_REDOX must be 1
ifeq ($(IS_REDOX),1)
FAILING_TESTS=
else
# Wrong modified time
FAILING_TESTS := futimens
# Crash, mmap issue
FAILING_TESTS += malloc/usable_size
# Not a FIFO
FAILING_TESTS += mkfifo
# Waitpid had EINTR
FAILING_TESTS += sigchld
# not triggering ERANGE
FAILING_TESTS += stdlib/ptsname
# Hang
FAILING_TESTS += sys_epoll/epollet
# Kernel hit todo!
FAILING_TESTS += sys_mman/fmap
# Hang
FAILING_TESTS += sys_socket/unixpeername
# Task failed successfully?
FAILING_TESTS += signals/pthread_kill-child
# Got EBADF
FAILING_TESTS += unistd/isatty
# Got EINVAL
FAILING_TESTS += unistd/link
# Signal kept unmasked
FAILING_TESTS += sigqueue
# Unwrap hit, written as TODO
FAILING_TESTS += pthread/customstack
# Returning garbage values
FAILING_TESTS += sys_resource/getrusage
# No times.h header
#FAILING_TESTS += time/times
# Outdated test
#FAILING_TESTS += netdb/netdb
endif
# Binaries that should generate the same output every time
EXPECT_NAMES=\
alloca \
arpainet \
assert \
ctype \
crypt/blowfish \
crypt/md5 \
crypt/pbkdf2 \
crypt/scrypt \
crypt/sha256 \
crypt/sha512 \
dirent/fdopendir \
dirent/scandir \
endian \
err \
errno \
error \
fcntl/create \
fcntl/fcntl \
fcntl/open \
fcntl/posix_fallocate \
features \
fnmatch \
glob \
iso646 \
libgen \
locale/duplocale \
locale/newlocale \
locale/setlocale \
math \
regex \
select \
setjmp \
sigaction \
sigaltstack \
signal \
stdio/all \
stdio/buffer \
stdio/dprintf \
stdio/fgets \
stdio/fputs \
stdio/fread \
stdio/freopen \
stdio/fseek \
stdio/fwrite \
stdio/getc_unget \
stdio/getline \
stdio/mutex \
stdio/popen \
stdio/printf \
stdio/putc_unlocked \
stdio/rename \
stdio/renameat \
stdio/scanf \
stdio/setvbuf \
stdio/sprintf \
stdio/printf_space_pad \
stdio/ungetc_ftell \
stdio/ungetc_multiple \
stdio/fscanf_offby1 \
stdio/fscanf \
stdio/printf_neg_pad \
stdlib/a64l \
stdlib/alloc \
stdlib/atof \
stdlib/atoi \
stdlib/div \
stdlib/getsubopt \
stdlib/mkostemps \
stdlib/qsort \
stdlib/rand \
stdlib/rand48 \
stdlib/random \
stdlib/strtod \
stdlib/strtol \
stdlib/strtoul \
stdlib/system \
string/mem \
string/memcpy \
string/memmem \
string/strcat \
string/strchr \
string/strchrnul \
string/strcpy \
string/strcspn \
string/strlen \
string/strncmp \
string/strpbrk \
string/strrchr \
string/strspn \
string/strstr \
string/strtok \
string/strtok_r \
string/strsep \
string/strsignal \
string/stpcpy \
string/stpncpy \
strings \
sys_socket/recv \
sys_socket/recvfrom \
sys_socket/unixrecv \
sys_socket/unixrecvfrom \
sys_socket/unixsocketpair \
sys_stat/chmod \
sys_stat/lstat \
sys_stat/fstatat \
sys_syslog/syslog \
time/asctime \
time/constants \
time/gmtime \
time/localtime \
time/localtime_r \
time/macros \
time/mktime \
time/strftime \
time/strptime \
time/time \
time/timegm \
time/tzset \
unistd/access \
unistd/alarm \
unistd/constants \
unistd/confstr \
unistd/dup \
unistd/exec \
unistd/fchdir \
unistd/fork \
unistd/fsync \
unistd/ftruncate \
unistd/getopt \
unistd/getopt_long \
unistd/pipe \
unistd/readlinkat \
unistd/rmdir \
unistd/sleep \
unistd/swab \
unistd/write \
wchar/fgetwc \
wchar/fwide \
wchar/mbrtowc \
wchar/mbsrtowcs \
wchar/printf-on-wchars \
wchar/putwchar \
wchar/wscanf \
wchar/ungetwc \
wchar/wprintf \
wchar/wcrtomb \
wchar/wcpcpy \
wchar/wcpncpy \
wchar/wcschr \
wchar/wcscspn \
wchar/wcsdup \
wchar/wcsrchr \
wchar/wcsrtombs \
wchar/wcsstr \
wchar/wcstod \
wchar/wcstok \
wchar/wcstol \
wchar/wcstoimax \
wchar/wcstoumax \
wchar/wcscasecmp \
wchar/wcsncasecmp \
wchar/wcsnlen \
wchar/wcsnrtombs \
wchar/wcswidth \
wctype/towlower \
wctype/towupper \
mknod \
mknodat
# Binaries that may generate varied output
VARIED_NAMES=\
dirent/main \
dirent/posix_getdents \
includes \
kill-waitpid \
limits \
net/if \
netdb/getaddrinfo \
netdb/getaddrinfo_null \
pthread/timedwait \
pty/forkpty \
psignal \
pwd \
sa_restart \
signals/kill-self \
signals/kill0-self \
signals/kill-invalid \
signals/kill-permission \
signals/killpg-esrch \
signals/killpg-invalid \
signals/killpg0-self \
signals/kill-group \
signals/kill-child \
signals/killpg-child \
signals/killpg-self \
signals/pthread_kill-invalid \
signals/pthread_kill-self \
signals/pthread_kill0-self \
signals/raise-compliance \
signals/sigismember-invalid \
signals/sigismember-valid \
signals/sigaddset-add \
signals/sigdelset-delete \
signals/signal-h \
signals/signal-h-2 \
signals/signal-handle_return \
signals/signal-handler \
signals/signal-handler2 \
signals/signal-ignore \
signals/signal-invalid \
signals/signal-uncatchable \
signals/sigprocmask-3 \
signals/sigprocmask-4 \
signals/sigprocmask-5 \
signals/sigprocmask-6 \
signals/sigprocmask-7 \
signals/sigprocmask-8 \
signals/sigprocmask-9 \
signals/sigprocmask-10 \
signals/sigprocmask-11 \
signals/sigpause-invalid \
signals/sigpause-revert \
signals/sigpause-suspend \
signals/sigprocmask-blocksingle \
signals/sigrelse-1 \
signals/sigrelse-2 \
signals/sigrelse-3 \
signals/sigset-1 \
signals/sigset-10 \
signals/sigset-2 \
signals/sigset-3 \
signals/sigset-4 \
signals/sigset-5 \
signals/sigset-9 \
stdio/ctermid \
stdio/tempnam \
stdio/tmpnam \
stdlib/bsearch \
stdlib/mktemp \
stdlib/realpath \
sys_epoll/epoll \
sys_mman/mmap \
sys_resource/constants \
sys_socket/getpeername \
sys_stat/stat \
sys_statvfs/statvfs \
sys_utsname/uname \
time/gettimeofday \
unistd/chdir \
unistd/getcwd \
unistd/gethostname \
unistd/getid \
unistd/getpagesize \
unistd/pathconf \
unistd/setid \
unistd/sysconf \
pthread/main \
pthread/cleanup \
pthread/exit \
pthread/extjoin \
pthread/once \
pthread/barrier \
pthread/rwlock_trylock \
pthread/rwlock_randtest \
pthread/mutex_recursive \
pthread/timeout \
pthread/tls \
grp/getgrouplist \
grp/getgroups \
grp/getgrgid_r \
grp/getgrnam_r \
grp/gr_iter \
waitid \
waitpid \
waitpid_multiple \
$(FAILING_TESTS)
# Tests that only working with when ld.so exist
DYNAMIC_ONLY_EXPECT_NAMES=\
dlfcn \
dlopen_scopes
# Tests that may produce different result when ld.so absent
STATIC_CHECK_EXPECT_NAMES=\
args \
constructor \
destructor \
stdlib/env \
unistd/brk \
tls
# Tests run with `expect` (require a .c file and an .exp file
# that takes the produced binary as the first argument)
EXPECT_INPUT_NAMES=\
unistd/getpass
# TODO: Dynamic linking doesn't work with NATIVE_LIBC=0
ifeq ($(IS_STATIC),1)
BINS+=$(patsubst %,$(BUILD)/bins_static/%,$(VARIED_NAMES))
EXPECT_BINS+=$(patsubst %,$(BUILD)/bins_static/%,$(EXPECT_NAMES))
EXPECT_BINS+=$(patsubst %,$(BUILD)/bins_static/%,$(STATIC_CHECK_EXPECT_NAMES))
ifeq ($(IS_REDOX),0)
EXPECT_INPUT_BINS=$(patsubst %,$(BUILD)/bins_expect_input/%,$(EXPECT_INPUT_NAMES))
endif
else
BINS+=$(patsubst %,$(BUILD)/bins_dynamic/%,$(VARIED_NAMES))
EXPECT_BINS+=$(patsubst %,$(BUILD)/bins_static/%,$(STATIC_CHECK_EXPECT_NAMES))
EXPECT_BINS+=$(patsubst %,$(BUILD)/bins_dynamic/%,$(EXPECT_NAMES))
EXPECT_BINS+=$(patsubst %,$(BUILD)/bins_dynamic/%,$(STATIC_CHECK_EXPECT_NAMES))
EXPECT_BINS+=$(patsubst %,$(BUILD)/bins_dynamic/%,$(DYNAMIC_ONLY_EXPECT_NAMES))
ifeq ($(IS_REDOX),0)
# TODO: redoxer does not have "expect" binary
EXPECT_INPUT_BINS=$(patsubst %,$(BUILD)/bins_expect_input/%,$(EXPECT_INPUT_NAMES))
endif
endif
+1 -1
View File
@@ -4,7 +4,7 @@
#include "test_helpers.h"
int main(int argc, char *argv[]) {
for(int i = 0; i < argc; i++) {
for(int i = 1; i < argc; i++) {
write(STDOUT_FILENO, argv[i], strlen(argv[i]));
write(STDOUT_FILENO, " ", 1);
}
+26
View File
@@ -0,0 +1,26 @@
#include <assert.h>
#include <crypt.h>
#include <string.h>
#include <unistd.h>
int main()
{
char *expected_output = "$2y$12$CJr4uRfziaGp4CWIBk0fB.I2tCOHYe3pomaWbC53/92p";
char *result = crypt("correctbatteryhorsestapler", "$2y$12$L6Bc/AlTQHyd9liGgGEZyO");
assert(strcmp(result, expected_output) == 0);
// Invalid salt for Blowfish
result = crypt("correctbatteryhorsestapler", "$2t$12$L6Bc/AlTQHyd9liGgGEZyO");
assert(result == NULL);
expected_output = "$2a$4$IAwt7hxuME3DekssMMTWU.xnJub2Xn45xK/oP.wWt3UC";
result = crypt("password", "$2a$04$UuTkLRZZ6QofpDOlMz32Mu");
assert(strcmp(result, expected_output) == 0);
// Invalid salt for Blowfish
result = "$2b$10$testtesttesttes";
result = crypt("correctbatteryhorsestapler", "$2y$12$L6Bc/AlTQHyd9liGgGEZyO");
assert(result != NULL);
return 0;
}
+38
View File
@@ -0,0 +1,38 @@
/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <crypt.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main () {
const char salt[] = "$1$saltstring";
char *cp;
int result = 0;
cp = crypt ("Hello world!", salt);
/* MD5 is disabled in FIPS mode. */
if (cp) {
result |= strcmp ("$1$saltstri$YMyguxXMBpd2TEZ.vS/3q1", cp);
if (!result)
printf("Success!\n");
}
return result;
}
+25
View File
@@ -0,0 +1,25 @@
#include <assert.h>
#include <crypt.h>
#include <string.h>
#include <unistd.h>
int main()
{
char *expected_output = "$8$3e8$salt$ZyTZgT5Pyp4CKdom6q6zHg0QrrAQO4ptWYCpWz4gu16";
char *result = crypt("pleaseletmein", "$8$3e8$salt");
assert(strcmp(result, expected_output) == 0);
// No salt
result = crypt("pleaseletmein", "$8$3e8$");
assert(result != NULL);
// Invalid encoded number for rounds
result = crypt("pleaseletmein", "$8$$salt");
assert(result == NULL);
// Invalid encoded number for rounds
result = crypt("pleaseletmein", "$8$.$salt");
assert(result == NULL);
return 0;
}
+25
View File
@@ -0,0 +1,25 @@
#include <assert.h>
#include <crypt.h>
#include <string.h>
#include <unistd.h>
int main()
{
char *expected_output = "$7$C6..../....$SodiumChloride$aAM7wxp7ayfEF.ZLedy2490m85oOR228oZTB7jPbmdG";
char *result = crypt("pleaseletmein", "$7$C6..../....SodiumChloride");
assert(strcmp(result, expected_output) == 0);
// No salt
result = crypt("pleaseletmein", "$7$C6..../....");
assert(result != NULL);
// Invalid encoded number for r
result = crypt("pleaseletmein", "$7$C6.../....SodiumChloride");
assert(result == NULL);
// Invalid encoded number for p
result = crypt("pleaseletmein", "$7$C6..../...SodiumChloride");
assert(result == NULL);
return 0;
}
+67
View File
@@ -0,0 +1,67 @@
/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <crypt.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static const struct
{
const char *salt;
const char *input;
const char *expected;
} tests[] =
{
{ "$5$saltstring", "Hello world!",
"$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5" },
{ "$5$rounds=10000$saltstringsaltstring", "Hello world!",
"$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2."
"opqey6IcA" },
{ "$5$rounds=5000$toolongsaltstring", "This is just a test",
"$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8"
"mGRcvxa5" },
{ "$5$rounds=1400$anotherlongsaltstring",
"a very much longer text to encrypt. This one even stretches over more"
"than one line.",
"$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12"
"oP84Bnq1" },
{ "$5$rounds=77777$short",
"we have a short salt string but not a short password",
"$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/" },
{ "$5$rounds=123456$asaltof16chars..", "a short string",
"$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/"
"cZKmF/wJvD" },
{ "$5$rounds=10$roundstoolow", "the minimum number is still observed",
"$5$rounds=1000$roundstoolow$yfvwcWrQ8l/K0DAWyuPMDNHpIVlTQebY9l/gL97"
"2bIC" },
};
const int ntests = sizeof(tests) / sizeof(tests[0]);
int main (void) {
int result = 0;
for (int i = 0; i < ntests; ++i){
char *cp = crypt (tests[i].input, tests[i].salt);
if (strcmp (cp, tests[i].expected) != 0) {
printf ("test %d: expected \"%s\", got \"%s\"\n", i, tests[i].expected, cp);
result = 1;
}
}
return result;
}
+72
View File
@@ -0,0 +1,72 @@
/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <crypt.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static const struct
{
const char *salt;
const char *input;
const char *expected;
} tests[] =
{
{ "$6$saltstring", "Hello world!",
"$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJu"
"esI68u4OTLiBFdcbYEdFCoEOfaS35inz1" },
{ "$6$rounds=10000$saltstringsaltstring", "Hello world!",
"$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sb"
"HbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v." },
{ "$6$rounds=5000$toolongsaltstring", "This is just a test",
"$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQ"
"zQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0" },
{ "$6$rounds=1400$anotherlongsaltstring",
"a very much longer text to encrypt. This one even stretches over more"
"than one line.",
"$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wP"
"vMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1" },
{ "$6$rounds=77777$short",
"we have a short salt string but not a short password",
"$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0g"
"ge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0" },
{ "$6$rounds=123456$asaltof16chars..", "a short string",
"$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwc"
"elCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1" },
{ "$6$rounds=10$roundstoolow", "the minimum number is still observed",
"$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1x"
"hLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX." },
};
const int ntests = sizeof(tests) / sizeof(tests[0]);
int main(void) {
int result = 0;
int i;
for (i = 0; i < ntests; ++i) {
char * cp = crypt(tests[i].input, tests[i].salt);
if (strcmp(cp, tests[i].expected) != 0) {
printf("test %d: expected \"%s\", got \"%s\"\n", i, tests[i].expected, cp);
result = 1;
}
}
return result;
}
+4 -1
View File
@@ -301,7 +301,9 @@ size_t num_test_cases = sizeof(test_cases) / sizeof(struct test_case);
int main(void) {
int retval = EXIT_SUCCESS;
for(int i = 0; i < num_test_cases; ++i) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
for(size_t i = 0; i < num_test_cases; ++i) {
struct test_case tc = test_cases[i];
CHECK_TEST(tc, isalnum, retval);
CHECK_TEST(tc, isalpha, retval);
@@ -320,6 +322,7 @@ int main(void) {
CHECK_TEST(tc, tolower, retval);
CHECK_TEST(tc, toupper, retval);
}
#pragma GCC diagnostic pop
if (retval == EXIT_SUCCESS) {
printf("Success: %d\n", retval);
+156
View File
@@ -0,0 +1,156 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
__attribute__((nonnull))
static bool check_dot(struct dirent* dirent) {
const char* dots[2] = {
".",
".."
};
for (size_t i = 0; i < 2; i++) {
if (strcmp(dots[i], dirent->d_name) == 0) {
return true;
}
}
return false;
}
int main(void) {
int status = EXIT_FAILURE;
char template[] = "/tmp/fdotest.XXXXXX";
if (!mkdtemp(template)) {
perror("mkdtemp");
goto bye;
}
const char* movies[] = {
"big_lebowski",
"blade_runner",
"grand_budapest_hotel",
"taxi_driver"
};
const size_t movies_len = sizeof(movies)/sizeof(char*);
char paths[sizeof(movies)/sizeof(char*)][PATH_MAX] = {0};
for (size_t i = 0; i < movies_len; ++i) {
// Concat the path
const size_t len = sizeof(template) - 1;
char buf[PATH_MAX] = {0};
memcpy(buf, template, len);
buf[len] = '/';
memcpy(&buf[len + 1], movies[i], strlen(movies[i]));
memcpy(paths[i], buf, PATH_MAX);
// And now create the file
int fd = open(buf, O_CREAT);
if (fd == -1) {
perror("open");
goto rmfiles;
}
close(fd);
}
// FIXME: Redox requires read perms for the dir while Linux/BSD don't.
int dir = open(template, O_DIRECTORY | O_RDONLY);
if (dir == -1) {
perror("open");
goto rmfiles;
}
DIR* iter = fdopendir(dir);
if (!iter) {
perror("fdopendir");
goto closedirfd;
}
for (size_t i = 0; i < movies_len; ++i) {
errno = 0;
struct dirent* dirent = readdir(iter);
if (!dirent) {
if (errno) {
perror("readdir");
}
fprintf(
stderr,
"Expected entry #%lu but directory stream is complete\n",
i
);
goto closediriter;
}
// Skip . and ..
if (check_dot(dirent)) {
continue;
}
// Check that the entry matches one of the names.
// readdir's order is indeterministic and looping over the names
// is simpler than qsort for a test.
for (size_t j = 0; j < movies_len; ++j) {
if (strcmp(movies[j], dirent->d_name) == 0) {
goto continue_outer;
}
}
fprintf(
stderr,
"Unexpected entry: %s\n",
dirent->d_name
);
goto closediriter;
continue_outer:
continue;
}
// fdclosedir is a BSD extension
#ifndef __GLIBC__
// fdclosedir returns ownership of the original fd.
int returned_fd = fdclosedir(iter);
// Internally, both closedir and fdclosedir consume the boxed DIR.
iter = NULL;
if (returned_fd != dir) {
fputs("fdclosedir returned the wrong descriptor\n", stderr);
goto closedirfd;
}
// Check that the file descriptor is still valid.
struct stat stat = {0};
if (fstatat(returned_fd, "", &stat, AT_EMPTY_PATH) == -1) {
perror("fstatat");
fputs("fdclosedir shouldn't have closed the fd\n", stderr);
goto closedirfd;
}
#endif
status = EXIT_SUCCESS;
closediriter:
if (iter) {
closedir(iter);
}
closedirfd:
close(dir);
rmfiles:
for (size_t i = 0; i < movies_len; ++i) {
if (strnlen(paths[i], PATH_MAX) > 4) {
unlink(paths[i]);
}
}
rmdir(template);
bye:
return status;
}
+2
View File
@@ -1,3 +1,4 @@
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
@@ -26,6 +27,7 @@ int main(void) {
puts("--- Testing rewind ---");
rewinddir(dir);
entry = readdir(dir);
assert(entry != NULL);
puts(entry->d_name);
// puts("--- Testing seek ---");
+53
View File
@@ -0,0 +1,53 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
#include "test_helpers.h"
#define BUFFER_SIZE 4096
#ifndef __GLIBC__
void read_and_print_directory(int fd) {
char buffer[BUFFER_SIZE];
long nread;
long bpos;
struct posix_dent *d;
for (;;) {
nread = posix_getdents(fd, buffer, BUFFER_SIZE, 0);
ERROR_IF(posix_getdents, nread, == -1);
UNEXP_IF(posix_getdents, nread, < 0);
if (nread == 0) {
break;
}
for (bpos = 0; bpos < nread;) {
d = (struct posix_dent *) (buffer + bpos);
printf(" ino = %-10lu name = %s\n", (unsigned long)d->d_ino, d->d_name);
bpos += d->d_reclen;
}
}
}
int main(void) {
int fd = open("example_dir/", O_RDONLY | O_DIRECTORY);
ERROR_IF(open, fd, == -1);
read_and_print_directory(fd);
off_t seek_result = lseek(fd, 0, SEEK_SET);
ERROR_IF(lseek, seek_result, == -1);
read_and_print_directory(fd);
close(fd);
}
#else
int main(void) {
// glibc doesn't support posix_getdents & O_DIRECTORY
}
#endif
+113 -19
View File
@@ -1,28 +1,122 @@
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#define SHARED_LIB "sharedlib.so"
int add(int a, int b)
{
return a + b;
int add(int a, int b) { return a + b; }
void test_dlopen_null() {
void *handle = dlopen(NULL, RTLD_LAZY);
if (!handle) {
printf("dlopen(NULL) failed: %s\n", dlerror());
exit(1);
}
int (*f)(int, int);
*(void **)(&f) = dlsym(handle, "add");
if (!f) {
printf("dlsym(handle, add) failed: %s\n", dlerror());
exit(2);
}
int a = 22;
int b = 33;
printf("add(%d, %d) = %d\n", a, b, f(a, b));
dlclose(handle);
}
void test_dlopen_libc() {
void *handle = dlopen("libc.so.6", RTLD_LAZY);
if (!handle) {
printf("dlopen(libc.so.6) failed\n");
exit(1);
}
int main()
{
void* handle = dlopen(NULL, RTLD_LAZY);
if (!handle) {
printf("dlopen(NULL) failed\n");
exit(1);
}
int (*f)(int, int) = dlsym(handle, "add");
if (!f) {
printf("dlsym(handle, add) failed\n");
exit(2);
}
int a = 22;
int b = 33;
printf("add(%d, %d) = %d\n", a, b, f(a, b));
int (*f)(const char *);
*(void **)(&f) = dlsym(handle, "puts");
if (!f) {
printf("dlsym(handle, puts) failed\n");
exit(2);
}
f("puts from dlopened libc");
dlclose(handle);
}
void test_dlsym_function() {
void *handle = dlopen(SHARED_LIB, RTLD_LAZY);
if (!handle) {
printf("dlopen(sharedlib.so) failed\n");
exit(1);
}
void (*f)();
*(void **)(&f) = dlsym(handle, "print");
if (!f) {
printf("dlsym(handle, print) failed\n");
exit(2);
}
f();
dlclose(handle);
}
void test_dlsym_global_var() {
void *handle = dlopen(SHARED_LIB, RTLD_LAZY);
if (!handle) {
printf("dlopen(sharedlib.so) failed\n");
exit(1);
}
int *global_var = dlsym(handle, "global_var");
if (!global_var) {
printf("dlsym(handle, global_var) failed\n");
exit(2);
}
printf("main: global_var == %d\n", *global_var);
dlclose(handle);
}
void test_dlsym_tls_var() {
void *handle = dlopen(SHARED_LIB, RTLD_LAZY);
if (!handle) {
printf("dlopen(sharedlib.so) failed\n");
exit(1);
}
int *tls_var = dlsym(handle, "tls_var");
if (!tls_var) {
printf("dlsym(handle, tls_var) failed\n");
exit(2);
}
printf("main: tls_var == %d\n", *tls_var);
dlclose(handle);
}
void test_dlunload(void) {
void *handle = dlopen(SHARED_LIB, RTLD_LAZY | RTLD_LOCAL);
void *handle2 = dlopen(SHARED_LIB, RTLD_LAZY | RTLD_LOCAL);
assert(handle == handle2 && handle);
assert(!dlclose(handle));
void *handle3 = dlopen(SHARED_LIB, RTLD_LAZY | RTLD_NOLOAD);
assert(handle3 == handle2);
assert(!dlclose(handle3));
assert(!dlclose(handle2));
void *handle4 = dlopen(SHARED_LIB, RTLD_LAZY | RTLD_NOLOAD);
assert(handle4 == NULL);
void *handle5 = dlopen(SHARED_LIB, RTLD_LAZY | RTLD_GLOBAL);
assert(handle5);
assert(!dlclose(handle5));
void *handle6 = dlopen(SHARED_LIB, RTLD_LAZY | RTLD_NOLOAD);
assert(handle6 == NULL);
}
int main() {
test_dlopen_null();
test_dlopen_libc();
test_dlsym_function();
test_dlsym_global_var();
test_dlsym_tls_var();
test_dlunload();
}
+38
View File
@@ -0,0 +1,38 @@
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
void *handle = dlopen("libfoobar.so", RTLD_LAZY | RTLD_LOCAL);
if (!handle) {
printf("dlopen(libfoobar.so): %s\n", dlerror());
return EXIT_FAILURE;
}
assert(dlsym(handle, "BAR") != NULL);
assert(dlsym(handle, "FOO") != NULL);
// not in the global scope
assert(dlsym(RTLD_DEFAULT, "BAR") == NULL);
assert(dlsym(RTLD_DEFAULT, "FOO") == NULL);
void *self = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
if (!self) {
printf("dlopen(NULL): %s\n", dlerror());
return EXIT_FAILURE;
}
assert(dlsym(self, "FOO") == NULL);
assert(dlsym(self, "BAR") == NULL);
assert(dlclose(self) == 0);
// Promote the library to the global scope.
assert(dlopen("libfoobar.so", /* RTLD_NOLOAD |*/ RTLD_NOW | RTLD_GLOBAL));
assert(dlsym(RTLD_DEFAULT, "FOO") != NULL);
assert(dlsym(RTLD_DEFAULT, "BAR") != NULL);
return EXIT_SUCCESS;
}
+75
View File
@@ -0,0 +1,75 @@
#include <assert.h>
#include <endian.h>
#include <stdint.h>
#include "test_helpers.h"
void to_be(uintmax_t in, uint8_t *out, size_t size) {
for (size_t i = 0; i < size; i++) {
out[i] = (in >> 8*(size - 1 - i)) & 0xff;
}
}
void to_le(uintmax_t in, uint8_t *out, size_t size) {
for (size_t i = 0; i < size; i++) {
out[i] = (in >> 8*i) & 0xff;
}
}
int main() {
uint16_t zero_u16 = 0;
assert(be16toh(zero_u16) == zero_u16);
assert(htobe16(zero_u16) == zero_u16);
assert(htole16(zero_u16) == zero_u16);
assert(le16toh(zero_u16) == zero_u16);
uint16_t u16_ne = 0x0123;
uint16_t u16_be, u16_le;
to_be(u16_ne, (uint8_t *)&u16_be, sizeof(uint16_t));
to_le(u16_ne, (uint8_t *)&u16_le, sizeof(uint16_t));
assert(be16toh(u16_be) == u16_ne);
assert(htobe16(u16_ne) == u16_be);
assert(htole16(u16_ne) == u16_le);
assert(le16toh(u16_le) == u16_ne);
uint32_t zero_u32 = 0;
assert(be32toh(zero_u32) == zero_u32);
assert(htobe32(zero_u32) == zero_u32);
assert(htole32(zero_u32) == zero_u32);
assert(le32toh(zero_u32) == zero_u32);
uint32_t u32_ne = 0x01234567;
uint32_t u32_be, u32_le;
to_be(u32_ne, (uint8_t *)&u32_be, sizeof(uint32_t));
to_le(u32_ne, (uint8_t *)&u32_le, sizeof(uint32_t));
assert(be32toh(u32_be) == u32_ne);
assert(htobe32(u32_ne) == u32_be);
assert(htole32(u32_ne) == u32_le);
assert(le32toh(u32_le) == u32_ne);
uint64_t zero_u64 = 0;
assert(be64toh(zero_u64) == zero_u64);
assert(htobe64(zero_u64) == zero_u64);
assert(htole64(zero_u64) == zero_u64);
assert(le64toh(zero_u64) == zero_u64);
uint64_t u64_ne = 0x0123456789ABCDEF;
uint64_t u64_be, u64_le;
to_be(u64_ne, (uint8_t *)&u64_be, sizeof(uint64_t));
to_le(u64_ne, (uint8_t *)&u64_le, sizeof(uint64_t));
assert(be64toh(u64_be) == u64_ne);
assert(htobe64(u64_ne) == u64_be);
assert(htole64(u64_ne) == u64_le);
assert(le64toh(u64_le) == u64_ne);
/* Test that the BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN macros are available */
/* It is in principle possible to have further endiannesses, like PDP_ENDIAN */
if (u64_ne == u64_le) {
assert(BYTE_ORDER == LITTLE_ENDIAN);
assert(BYTE_ORDER != BIG_ENDIAN);
}
if (u64_ne == u64_be) {
assert(BYTE_ORDER == BIG_ENDIAN);
assert(BYTE_ORDER != LITTLE_ENDIAN);
}
}
+61
View File
@@ -0,0 +1,61 @@
#include <err.h>
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
// does not compile with glibc
#ifndef __GLIBC__
__attribute__((nonnull(2)))
static void vwarn_test(int code, const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
vwarnc(code, fmt, ap);
va_end(ap);
}
static void log_to_stdout(void) {
err_set_file(stdout);
warnc(ENOENT, "Dang it, Bobby.");
err_set_file(NULL);
}
void user_callback(int code) {
printf("Exiting due to error code: %d\n", code);
}
int main(void) {
err_set_exit(user_callback);
// Set errno to a known value for verifiable messages
// (Also, "Owner died" is just too funny not to use)
errno = EOWNERDEAD;
warn("Ran out of coffee");
warnx("%s pulled out your ethernet cable", "Cat");
warnc(EACCES, "Eat %d cookies", 42);
vwarn_test(EBADE, "Potato, %s", "krumpli");
// Set the sink to stdout then back to stderr
log_to_stdout();
warnc(EPERM,
"I'm sorry, Dave. I'm afraid I can't do that."
);
// As long as one err function works they should all work since
// two functions handle everything internally.
errc(EXIT_SUCCESS, EUSERS, "Bye. It's crowded.");
// Unreachable
puts("err did not exit");
return EXIT_FAILURE;
}
#else
int main(void) {
exit(0);
}
#endif
+668 -3
View File
@@ -1,13 +1,678 @@
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include "test_helpers.h"
int main(int argc, char **argv) {
puts(argv[0]);
puts(program_invocation_name);
// Recent POSIX requires E2BIG, EACCESS etc. to be available as macros
#ifdef E2BIG
puts("E2BIG macro available");
#else
puts("E2BIG macro missing");
#endif /* E2BIG */
#ifdef EACCES
puts("EACCES macro available");
#else
puts("EACCES macro missing");
#endif /* EACCES */
#ifdef EADDRINUSE
puts("EADDRINUSE macro available");
#else
puts("EADDRINUSE macro missing");
#endif /* EADDRINUSE */
#ifdef EADDRNOTAVAIL
puts("EADDRNOTAVAIL macro available");
#else
puts("EADDRNOTAVAIL macro missing");
#endif /* EADDRNOTAVAIL */
#ifdef EADV
puts("EADV macro available");
#else
puts("EADV macro missing");
#endif /* EADV */
#ifdef EAFNOSUPPORT
puts("EAFNOSUPPORT macro available");
#else
puts("EAFNOSUPPORT macro missing");
#endif /* EAFNOSUPPORT */
#ifdef EAGAIN
puts("EAGAIN macro available");
#else
puts("EAGAIN macro missing");
#endif /* EAGAIN */
#ifdef EALREADY
puts("EALREADY macro available");
#else
puts("EALREADY macro missing");
#endif /* EALREADY */
#ifdef EBADE
puts("EBADE macro available");
#else
puts("EBADE macro missing");
#endif /* EBADE */
#ifdef EBADF
puts("EBADF macro available");
#else
puts("EBADF macro missing");
#endif /* EBADF */
#ifdef EBADFD
puts("EBADFD macro available");
#else
puts("EBADFD macro missing");
#endif /* EBADFD */
#ifdef EBADMSG
puts("EBADMSG macro available");
#else
puts("EBADMSG macro missing");
#endif /* EBADMSG */
#ifdef EBADR
puts("EBADR macro available");
#else
puts("EBADR macro missing");
#endif /* EBADR */
#ifdef EBADRQC
puts("EBADRQC macro available");
#else
puts("EBADRQC macro missing");
#endif /* EBADRQC */
#ifdef EBADSLT
puts("EBADSLT macro available");
#else
puts("EBADSLT macro missing");
#endif /* EBADSLT */
#ifdef EBFONT
puts("EBFONT macro available");
#else
puts("EBFONT macro missing");
#endif /* EBFONT */
#ifdef EBUSY
puts("EBUSY macro available");
#else
puts("EBUSY macro missing");
#endif /* EBUSY */
#ifdef ECANCELED
puts("ECANCELED macro available");
#else
puts("ECANCELED macro missing");
#endif /* ECANCELED */
#ifdef ECHILD
puts("ECHILD macro available");
#else
puts("ECHILD macro missing");
#endif /* ECHILD */
#ifdef ECHRNG
puts("ECHRNG macro available");
#else
puts("ECHRNG macro missing");
#endif /* ECHRNG */
#ifdef ECOMM
puts("ECOMM macro available");
#else
puts("ECOMM macro missing");
#endif /* ECOMM */
#ifdef ECONNABORTED
puts("ECONNABORTED macro available");
#else
puts("ECONNABORTED macro missing");
#endif /* ECONNABORTED */
#ifdef ECONNREFUSED
puts("ECONNREFUSED macro available");
#else
puts("ECONNREFUSED macro missing");
#endif /* ECONNREFUSED */
#ifdef ECONNRESET
puts("ECONNRESET macro available");
#else
puts("ECONNRESET macro missing");
#endif /* ECONNRESET */
#ifdef EDEADLK
puts("EDEADLK macro available");
#else
puts("EDEADLK macro missing");
#endif /* EDEADLK */
#ifdef EDEADLOCK
puts("EDEADLOCK macro available");
#else
puts("EDEADLOCK macro missing");
#endif /* EDEADLOCK */
#ifdef EDESTADDRREQ
puts("EDESTADDRREQ macro available");
#else
puts("EDESTADDRREQ macro missing");
#endif /* EDESTADDRREQ */
#ifdef EDOM
puts("EDOM macro available");
#else
puts("EDOM macro missing");
#endif /* EDOM */
#ifdef EDOTDOT
puts("EDOTDOT macro available");
#else
puts("EDOTDOT macro missing");
#endif /* EDOTDOT */
#ifdef EDQUOT
puts("EDQUOT macro available");
#else
puts("EDQUOT macro missing");
#endif /* EDQUOT */
#ifdef EEXIST
puts("EEXIST macro available");
#else
puts("EEXIST macro missing");
#endif /* EEXIST */
#ifdef EFAULT
puts("EFAULT macro available");
#else
puts("EFAULT macro missing");
#endif /* EFAULT */
#ifdef EFBIG
puts("EFBIG macro available");
#else
puts("EFBIG macro missing");
#endif /* EFBIG */
#ifdef EHOSTDOWN
puts("EHOSTDOWN macro available");
#else
puts("EHOSTDOWN macro missing");
#endif /* EHOSTDOWN */
#ifdef EHOSTUNREACH
puts("EHOSTUNREACH macro available");
#else
puts("EHOSTUNREACH macro missing");
#endif /* EHOSTUNREACH */
#ifdef EIDRM
puts("EIDRM macro available");
#else
puts("EIDRM macro missing");
#endif /* EIDRM */
#ifdef EILSEQ
puts("EILSEQ macro available");
#else
puts("EILSEQ macro missing");
#endif /* EILSEQ */
#ifdef EINPROGRESS
puts("EINPROGRESS macro available");
#else
puts("EINPROGRESS macro missing");
#endif /* EINPROGRESS */
#ifdef EINTR
puts("EINTR macro available");
#else
puts("EINTR macro missing");
#endif /* EINTR */
#ifdef EINVAL
puts("EINVAL macro available");
#else
puts("EINVAL macro missing");
#endif /* EINVAL */
#ifdef EIO
puts("EIO macro available");
#else
puts("EIO macro missing");
#endif /* EIO */
#ifdef EISCONN
puts("EISCONN macro available");
#else
puts("EISCONN macro missing");
#endif /* EISCONN */
#ifdef EISDIR
puts("EISDIR macro available");
#else
puts("EISDIR macro missing");
#endif /* EISDIR */
#ifdef EISNAM
puts("EISNAM macro available");
#else
puts("EISNAM macro missing");
#endif /* EISNAM */
#ifdef EKEYEXPIRED
puts("EKEYEXPIRED macro available");
#else
puts("EKEYEXPIRED macro missing");
#endif /* EKEYEXPIRED */
#ifdef EKEYREJECTED
puts("EKEYREJECTED macro available");
#else
puts("EKEYREJECTED macro missing");
#endif /* EKEYREJECTED */
#ifdef EKEYREVOKED
puts("EKEYREVOKED macro available");
#else
puts("EKEYREVOKED macro missing");
#endif /* EKEYREVOKED */
#ifdef EL2HLT
puts("EL2HLT macro available");
#else
puts("EL2HLT macro missing");
#endif /* EL2HLT */
#ifdef EL2NSYNC
puts("EL2NSYNC macro available");
#else
puts("EL2NSYNC macro missing");
#endif /* EL2NSYNC */
#ifdef EL3HLT
puts("EL3HLT macro available");
#else
puts("EL3HLT macro missing");
#endif /* EL3HLT */
#ifdef EL3RST
puts("EL3RST macro available");
#else
puts("EL3RST macro missing");
#endif /* EL3RST */
#ifdef ELIBACC
puts("ELIBACC macro available");
#else
puts("ELIBACC macro missing");
#endif /* ELIBACC */
#ifdef ELIBBAD
puts("ELIBBAD macro available");
#else
puts("ELIBBAD macro missing");
#endif /* ELIBBAD */
#ifdef ELIBEXEC
puts("ELIBEXEC macro available");
#else
puts("ELIBEXEC macro missing");
#endif /* ELIBEXEC */
#ifdef ELIBMAX
puts("ELIBMAX macro available");
#else
puts("ELIBMAX macro missing");
#endif /* ELIBMAX */
#ifdef ELIBSCN
puts("ELIBSCN macro available");
#else
puts("ELIBSCN macro missing");
#endif /* ELIBSCN */
#ifdef ELNRNG
puts("ELNRNG macro available");
#else
puts("ELNRNG macro missing");
#endif /* ELNRNG */
#ifdef ELOOP
puts("ELOOP macro available");
#else
puts("ELOOP macro missing");
#endif /* ELOOP */
#ifdef EMEDIUMTYPE
puts("EMEDIUMTYPE macro available");
#else
puts("EMEDIUMTYPE macro missing");
#endif /* EMEDIUMTYPE */
#ifdef EMFILE
puts("EMFILE macro available");
#else
puts("EMFILE macro missing");
#endif /* EMFILE */
#ifdef EMLINK
puts("EMLINK macro available");
#else
puts("EMLINK macro missing");
#endif /* EMLINK */
#ifdef EMSGSIZE
puts("EMSGSIZE macro available");
#else
puts("EMSGSIZE macro missing");
#endif /* EMSGSIZE */
#ifdef EMULTIHOP
puts("EMULTIHOP macro available");
#else
puts("EMULTIHOP macro missing");
#endif /* EMULTIHOP */
#ifdef ENAMETOOLONG
puts("ENAMETOOLONG macro available");
#else
puts("ENAMETOOLONG macro missing");
#endif /* ENAMETOOLONG */
#ifdef ENAVAIL
puts("ENAVAIL macro available");
#else
puts("ENAVAIL macro missing");
#endif /* ENAVAIL */
#ifdef ENETDOWN
puts("ENETDOWN macro available");
#else
puts("ENETDOWN macro missing");
#endif /* ENETDOWN */
#ifdef ENETRESET
puts("ENETRESET macro available");
#else
puts("ENETRESET macro missing");
#endif /* ENETRESET */
#ifdef ENETUNREACH
puts("ENETUNREACH macro available");
#else
puts("ENETUNREACH macro missing");
#endif /* ENETUNREACH */
#ifdef ENFILE
puts("ENFILE macro available");
#else
puts("ENFILE macro missing");
#endif /* ENFILE */
#ifdef ENOANO
puts("ENOANO macro available");
#else
puts("ENOANO macro missing");
#endif /* ENOANO */
#ifdef ENOBUFS
puts("ENOBUFS macro available");
#else
puts("ENOBUFS macro missing");
#endif /* ENOBUFS */
#ifdef ENOCSI
puts("ENOCSI macro available");
#else
puts("ENOCSI macro missing");
#endif /* ENOCSI */
#ifdef ENODATA
puts("ENODATA macro available");
#else
puts("ENODATA macro missing");
#endif /* ENODATA */
#ifdef ENODEV
puts("ENODEV macro available");
#else
puts("ENODEV macro missing");
#endif /* ENODEV */
#ifdef ENOENT
puts("ENOENT macro available");
#else
puts("ENOENT macro missing");
#endif /* ENOENT */
#ifdef ENOEXEC
puts("ENOEXEC macro available");
#else
puts("ENOEXEC macro missing");
#endif /* ENOEXEC */
#ifdef ENOKEY
puts("ENOKEY macro available");
#else
puts("ENOKEY macro missing");
#endif /* ENOKEY */
#ifdef ENOLCK
puts("ENOLCK macro available");
#else
puts("ENOLCK macro missing");
#endif /* ENOLCK */
#ifdef ENOLINK
puts("ENOLINK macro available");
#else
puts("ENOLINK macro missing");
#endif /* ENOLINK */
#ifdef ENOMEDIUM
puts("ENOMEDIUM macro available");
#else
puts("ENOMEDIUM macro missing");
#endif /* ENOMEDIUM */
#ifdef ENOMEM
puts("ENOMEM macro available");
#else
puts("ENOMEM macro missing");
#endif /* ENOMEM */
#ifdef ENOMSG
puts("ENOMSG macro available");
#else
puts("ENOMSG macro missing");
#endif /* ENOMSG */
#ifdef ENONET
puts("ENONET macro available");
#else
puts("ENONET macro missing");
#endif /* ENONET */
#ifdef ENOPKG
puts("ENOPKG macro available");
#else
puts("ENOPKG macro missing");
#endif /* ENOPKG */
#ifdef ENOPROTOOPT
puts("ENOPROTOOPT macro available");
#else
puts("ENOPROTOOPT macro missing");
#endif /* ENOPROTOOPT */
#ifdef ENOSPC
puts("ENOSPC macro available");
#else
puts("ENOSPC macro missing");
#endif /* ENOSPC */
#ifdef ENOSR
puts("ENOSR macro available");
#else
puts("ENOSR macro missing");
#endif /* ENOSR */
#ifdef ENOSTR
puts("ENOSTR macro available");
#else
puts("ENOSTR macro missing");
#endif /* ENOSTR */
#ifdef ENOSYS
puts("ENOSYS macro available");
#else
puts("ENOSYS macro missing");
#endif /* ENOSYS */
#ifdef ENOTBLK
puts("ENOTBLK macro available");
#else
puts("ENOTBLK macro missing");
#endif /* ENOTBLK */
#ifdef ENOTCONN
puts("ENOTCONN macro available");
#else
puts("ENOTCONN macro missing");
#endif /* ENOTCONN */
#ifdef ENOTDIR
puts("ENOTDIR macro available");
#else
puts("ENOTDIR macro missing");
#endif /* ENOTDIR */
#ifdef ENOTEMPTY
puts("ENOTEMPTY macro available");
#else
puts("ENOTEMPTY macro missing");
#endif /* ENOTEMPTY */
#ifdef ENOTNAM
puts("ENOTNAM macro available");
#else
puts("ENOTNAM macro missing");
#endif /* ENOTNAM */
#ifdef ENOTRECOVERABLE
puts("ENOTRECOVERABLE macro available");
#else
puts("ENOTRECOVERABLE macro missing");
#endif /* ENOTRECOVERABLE */
#ifdef ENOTSOCK
puts("ENOTSOCK macro available");
#else
puts("ENOTSOCK macro missing");
#endif /* ENOTSOCK */
#ifdef ENOTSUP
puts("ENOTSUP macro available");
#else
puts("ENOTSUP macro missing");
#endif /* ENOTSUP */
#ifdef ENOTTY
puts("ENOTTY macro available");
#else
puts("ENOTTY macro missing");
#endif /* ENOTTY */
#ifdef ENOTUNIQ
puts("ENOTUNIQ macro available");
#else
puts("ENOTUNIQ macro missing");
#endif /* ENOTUNIQ */
#ifdef ENXIO
puts("ENXIO macro available");
#else
puts("ENXIO macro missing");
#endif /* ENXIO */
#ifdef EOPNOTSUPP
puts("EOPNOTSUPP macro available");
#else
puts("EOPNOTSUPP macro missing");
#endif /* EOPNOTSUPP */
#ifdef EOVERFLOW
puts("EOVERFLOW macro available");
#else
puts("EOVERFLOW macro missing");
#endif /* EOVERFLOW */
#ifdef EOWNERDEAD
puts("EOWNERDEAD macro available");
#else
puts("EOWNERDEAD macro missing");
#endif /* EOWNERDEAD */
#ifdef EPERM
puts("EPERM macro available");
#else
puts("EPERM macro missing");
#endif /* EPERM */
#ifdef EPFNOSUPPORT
puts("EPFNOSUPPORT macro available");
#else
puts("EPFNOSUPPORT macro missing");
#endif /* EPFNOSUPPORT */
#ifdef EPIPE
puts("EPIPE macro available");
#else
puts("EPIPE macro missing");
#endif /* EPIPE */
#ifdef EPROTO
puts("EPROTO macro available");
#else
puts("EPROTO macro missing");
#endif /* EPROTO */
#ifdef EPROTONOSUPPORT
puts("EPROTONOSUPPORT macro available");
#else
puts("EPROTONOSUPPORT macro missing");
#endif /* EPROTONOSUPPORT */
#ifdef EPROTOTYPE
puts("EPROTOTYPE macro available");
#else
puts("EPROTOTYPE macro missing");
#endif /* EPROTOTYPE */
#ifdef ERANGE
puts("ERANGE macro available");
#else
puts("ERANGE macro missing");
#endif /* ERANGE */
#ifdef EREMCHG
puts("EREMCHG macro available");
#else
puts("EREMCHG macro missing");
#endif /* EREMCHG */
#ifdef EREMOTE
puts("EREMOTE macro available");
#else
puts("EREMOTE macro missing");
#endif /* EREMOTE */
#ifdef EREMOTEIO
puts("EREMOTEIO macro available");
#else
puts("EREMOTEIO macro missing");
#endif /* EREMOTEIO */
#ifdef ERESTART
puts("ERESTART macro available");
#else
puts("ERESTART macro missing");
#endif /* ERESTART */
#ifdef EROFS
puts("EROFS macro available");
#else
puts("EROFS macro missing");
#endif /* EROFS */
#ifdef ESHUTDOWN
puts("ESHUTDOWN macro available");
#else
puts("ESHUTDOWN macro missing");
#endif /* ESHUTDOWN */
#ifdef ESOCKTNOSUPPORT
puts("ESOCKTNOSUPPORT macro available");
#else
puts("ESOCKTNOSUPPORT macro missing");
#endif /* ESOCKTNOSUPPORT */
#ifdef ESPIPE
puts("ESPIPE macro available");
#else
puts("ESPIPE macro missing");
#endif /* ESPIPE */
#ifdef ESRCH
puts("ESRCH macro available");
#else
puts("ESRCH macro missing");
#endif /* ESRCH */
#ifdef ESRMNT
puts("ESRMNT macro available");
#else
puts("ESRMNT macro missing");
#endif /* ESRMNT */
#ifdef ESTALE
puts("ESTALE macro available");
#else
puts("ESTALE macro missing");
#endif /* ESTALE */
#ifdef ESTRPIPE
puts("ESTRPIPE macro available");
#else
puts("ESTRPIPE macro missing");
#endif /* ESTRPIPE */
#ifdef ETIME
puts("ETIME macro available");
#else
puts("ETIME macro missing");
#endif /* ETIME */
#ifdef ETIMEDOUT
puts("ETIMEDOUT macro available");
#else
puts("ETIMEDOUT macro missing");
#endif /* ETIMEDOUT */
#ifdef ETOOMANYREFS
puts("ETOOMANYREFS macro available");
#else
puts("ETOOMANYREFS macro missing");
#endif /* ETOOMANYREFS */
#ifdef ETXTBSY
puts("ETXTBSY macro available");
#else
puts("ETXTBSY macro missing");
#endif /* ETXTBSY */
#ifdef EUCLEAN
puts("EUCLEAN macro available");
#else
puts("EUCLEAN macro missing");
#endif /* EUCLEAN */
#ifdef EUNATCH
puts("EUNATCH macro available");
#else
puts("EUNATCH macro missing");
#endif /* EUNATCH */
#ifdef EUSERS
puts("EUSERS macro available");
#else
puts("EUSERS macro missing");
#endif /* EUSERS */
#ifdef EWOULDBLOCK
puts("EWOULDBLOCK macro available");
#else
puts("EWOULDBLOCK macro missing");
#endif /* EWOULDBLOCK */
#ifdef EXDEV
puts("EXDEV macro available");
#else
puts("EXDEV macro missing");
#endif /* EXDEV */
#ifdef EXFULL
puts("EXFULL macro available");
#else
puts("EXFULL macro missing");
#endif /* EXFULL */
assert(argc > 0);
puts(program_invocation_short_name);
program_invocation_name = "yes, you can change this";
argv[0] = "changed to argv[0]";
program_invocation_name = "changed to program_invocation_name";
program_invocation_short_name = "changed to program_invocation_short_name";
puts(argv[0]);
puts(program_invocation_name);
+39 -5
View File
@@ -1,10 +1,15 @@
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "test_helpers.h"
// does not compile with glibc
#ifndef __GLIBC__
int main(void) {
chdir("nonexistent");
int err = errno;
@@ -12,15 +17,44 @@ int main(void) {
printf("errno: %d = %s\n", err, strerror(errno));
perror("perror");
char buf1[256];
char buf1[256] = {0};
int ret1 = strerror_r(err, buf1, 256);
printf("errno: %d = %s, return: %d\n", err, buf1, ret1);
char buf2[3];
char buf2[3] = {0};
int ret2 = strerror_r(err, buf2, 3);
printf("errno: %d = %s, return: %d\n", err, buf2, ret2);
char buf3[256] = {0};
int ret3 = strerror_r(err, buf3, 0);
printf("errno: %d = %s, return: %d\n", err, buf3, ret3);
// Test that the statically allocated buffer doesn't overflow
for (int code = EPERM; code < ENOTRECOVERABLE; ++code) {
const char* message = strerror(code);
if (!message) {
errx(EXIT_FAILURE,
"Expected message for error code: %d",
code
);
}
}
const char* actual_error = strerror(INT_MAX);
char expected_error[256] = {0};
sprintf(expected_error, "Unknown error %d", INT_MAX);
if (strncmp(expected_error, actual_error, 25) != 0) {
errx(EXIT_FAILURE,
"Expected: %s\nGot: %s",
expected_error, actual_error
);
}
return EXIT_SUCCESS;
}
#else
int main(void) {
exit(0);
}
#endif
+1 -1
View File
@@ -1 +1 @@
bins_dynamic/args test args
test args
@@ -0,0 +1 @@
Success!
+6
View File
@@ -0,0 +1,6 @@
add(22, 33) = 55
puts from dlopened libc
sharedlib: global_var == 42
sharedlib: tls_var == 21
main: global_var == 42
main: tls_var == 21
+6
View File
@@ -0,0 +1,6 @@
err: Ran out of coffee: Owner died
err: Cat pulled out your ethernet cable
err: Eat 42 cookies: Permission denied
err: Potato, krumpli: Invalid exchange
err: I'm sorry, Dave. I'm afraid I can't do that.: Operation not permitted
err: Bye. It's crowded.: Too many users
+2
View File
@@ -0,0 +1,2 @@
err: Dang it, Bobby.: No such file or directory
Exiting due to error code: 87
+135 -5
View File
@@ -1,6 +1,136 @@
bins_dynamic/errno
bins_dynamic/errno
E2BIG macro available
EACCES macro available
EADDRINUSE macro available
EADDRNOTAVAIL macro available
EADV macro available
EAFNOSUPPORT macro available
EAGAIN macro available
EALREADY macro available
EBADE macro available
EBADF macro available
EBADFD macro available
EBADMSG macro available
EBADR macro available
EBADRQC macro available
EBADSLT macro available
EBFONT macro available
EBUSY macro available
ECANCELED macro available
ECHILD macro available
ECHRNG macro available
ECOMM macro available
ECONNABORTED macro available
ECONNREFUSED macro available
ECONNRESET macro available
EDEADLK macro available
EDEADLOCK macro available
EDESTADDRREQ macro available
EDOM macro available
EDOTDOT macro available
EDQUOT macro available
EEXIST macro available
EFAULT macro available
EFBIG macro available
EHOSTDOWN macro available
EHOSTUNREACH macro available
EIDRM macro available
EILSEQ macro available
EINPROGRESS macro available
EINTR macro available
EINVAL macro available
EIO macro available
EISCONN macro available
EISDIR macro available
EISNAM macro available
EKEYEXPIRED macro available
EKEYREJECTED macro available
EKEYREVOKED macro available
EL2HLT macro available
EL2NSYNC macro available
EL3HLT macro available
EL3RST macro available
ELIBACC macro available
ELIBBAD macro available
ELIBEXEC macro available
ELIBMAX macro available
ELIBSCN macro available
ELNRNG macro available
ELOOP macro available
EMEDIUMTYPE macro available
EMFILE macro available
EMLINK macro available
EMSGSIZE macro available
EMULTIHOP macro available
ENAMETOOLONG macro available
ENAVAIL macro available
ENETDOWN macro available
ENETRESET macro available
ENETUNREACH macro available
ENFILE macro available
ENOANO macro available
ENOBUFS macro available
ENOCSI macro available
ENODATA macro available
ENODEV macro available
ENOENT macro available
ENOEXEC macro available
ENOKEY macro available
ENOLCK macro available
ENOLINK macro available
ENOMEDIUM macro available
ENOMEM macro available
ENOMSG macro available
ENONET macro available
ENOPKG macro available
ENOPROTOOPT macro available
ENOSPC macro available
ENOSR macro available
ENOSTR macro available
ENOSYS macro available
ENOTBLK macro available
ENOTCONN macro available
ENOTDIR macro available
ENOTEMPTY macro available
ENOTNAM macro available
ENOTRECOVERABLE macro available
ENOTSOCK macro available
ENOTSUP macro available
ENOTTY macro available
ENOTUNIQ macro available
ENXIO macro available
EOPNOTSUPP macro available
EOVERFLOW macro available
EOWNERDEAD macro available
EPERM macro available
EPFNOSUPPORT macro available
EPIPE macro available
EPROTO macro available
EPROTONOSUPPORT macro available
EPROTOTYPE macro available
ERANGE macro available
EREMCHG macro available
EREMOTE macro available
EREMOTEIO macro available
ERESTART macro available
EROFS macro available
ESHUTDOWN macro available
ESOCKTNOSUPPORT macro available
ESPIPE macro available
ESRCH macro available
ESRMNT macro available
ESTALE macro available
ESTRPIPE macro available
ETIME macro available
ETIMEDOUT macro available
ETOOMANYREFS macro available
ETXTBSY macro available
EUCLEAN macro available
EUNATCH macro available
EUSERS macro available
EWOULDBLOCK macro available
EXDEV macro available
EXFULL macro available
errno
yes, you can change this
yes, you can change this
yes, you can change this
changed to argv[0]
changed to program_invocation_name
changed to program_invocation_short_name
@@ -29,3 +29,4 @@ Should fail:
"[a!][a!]" doesn't match "ab"
"hello[/+]world" doesn't match "hello/world"
"hello world" doesn't match "HELLO WORLD"
"********************a" doesn't match "xxxxxxxxxxxxxxxxxxxxb"
+33
View File
@@ -0,0 +1,33 @@
0 and 0: 0
1 and 0: 0
0 and 1: 0
1 and 1: 1
0 and_eq 0: 0
1 and_eq 0: 0
0 and_eq 1: 0
1 and_eq 1: 1
a bitand b: 8
a bitor b: 14
compl a: 245
not 0: 1
not 1: 0
0 not_eq 0: 0
1 not_eq 0: 1
0 not_eq 1: 0
1 not_eq 1: 1
0 or 0: 0
1 or 0: 1
0 or 1: 1
1 or 1: 1
0 or_eq 0: 0
1 or_eq 0: 1
0 or_eq 1: 1
1 or_eq 1: 1
0 xor 0: 0
1 xor 0: 1
0 xor 1: 1
1 xor 1: 0
0 xor_eq 0: 0
1 xor_eq 0: 1
0 xor_eq 1: 1
1 xor_eq 1: 0
@@ -0,0 +1,2 @@
malloc: 27 bytes
malloc_usable_size: 48 bytes
@@ -0,0 +1,5 @@
Set regs
Set regs
Set regs
Set regs
Child exited with status 0

Some files were not shown because too many files have changed in this diff Show More