Skip to content

Commit

Permalink
Refactor make rules, fix stage 0 sizeof test
Browse files Browse the repository at this point in the history
  • Loading branch information
ChAoSUnItY committed Dec 6, 2024
1 parent 4103a5b commit b763ec7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
make clean config
make check-snapshots || exit 1
make distclean config ARCH=arm
make check-all || exit 1
make check || exit 1
make distclean config ARCH=riscv
make check-all || exit 1
make check || exit 1
host-arm:
runs-on: ubuntu-22.04
Expand All @@ -44,7 +44,7 @@ jobs:
apt-get install -q -y build-essential
run: |
make config ARCH=arm
make check-all || exit 1
make check || exit 1
coding-style:
runs-on: ubuntu-22.04
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ $(OUT)/tests/%.elf: tests/%.c $(OUT)/$(STAGE0)
chmod +x $@ ; $(PRINTF) "Running $@ ...\n"
$(Q)$(TARGET_EXEC) $@ && $(call pass)

check: $(OUT)/$(STAGE0) $(TESTBINS) tests/driver.sh
check: check-stage1 check-stage2 check-snapshots

check-stage1: $(OUT)/$(STAGE0) $(TESTBINS) tests/driver.sh
$(VECHO) " TEST STAGE 0\n"
tests/driver.sh

Expand All @@ -64,8 +66,6 @@ check-snapshots: $(OUT)/$(STAGE0) $(SNAPSHOTS) tests/check-snapshots.sh
$(VECHO) " TEST SNAPSHOTS\n"
tests/check-snapshots.sh

check-all: $(OUT)/$(STAGE2) $(TESTBINS) check check-stage2

$(OUT)/%.o: %.c
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -c -MMD -MF $@.d $<
Expand Down
14 changes: 10 additions & 4 deletions tests/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ set -u

readonly SHECC="$PWD/out/shecc"

if [ "$(getconf LONG_BIT)" == "64" ]; then
readonly HOST_PTR_SIZE=8
else
readonly HOST_PTR_SIZE=4
fi

# try - test shecc with given code
# Usage:
# - try exit_code input_code
Expand Down Expand Up @@ -408,10 +414,10 @@ items 20 "int *p; int a[3]; a[0] = 10; a[1] = 20; a[2] = 30; p = a; p+=1; return
expr 4 "sizeof(int)";
expr 1 "sizeof(char)";
# sizeof pointers
expr 8 "sizeof(void*)";
expr 8 "sizeof(_Bool*)";
expr 8 "sizeof(char*)";
expr 8 "sizeof(int*)";
expr $HOST_PTR_SIZE "sizeof(void*)";
expr $HOST_PTR_SIZE "sizeof(_Bool*)";
expr $HOST_PTR_SIZE "sizeof(char*)";
expr $HOST_PTR_SIZE "sizeof(int*)";

# switch-case
items 10 "int a; a = 0; switch (3) { case 0: return 2; case 3: a = 10; break; case 1: return 0; } return a;"
Expand Down

0 comments on commit b763ec7

Please sign in to comment.