Skip to content

Commit

Permalink
[CI] Add csmith
Browse files Browse the repository at this point in the history
  • Loading branch information
fuhsnn committed Dec 3, 2024
1 parent 2ece175 commit 2530898
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 77 deletions.
77 changes: 0 additions & 77 deletions .github/workflows/linux_thirdparty.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/weekly_csmith.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: weekly-csmith

on:
schedule:
- cron: '20 05 * * 2'

jobs:
run_csmith:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Get deps
run: sudo apt-get update && apt-get install -y --no-install-recommends clang csmith libcsmith-dev
- name: Build
run: clang -Wno-switch *.c -O3 -flto=auto -march=native -fsanitize=address -o slimcc_asan
- name: Run csmith
run: |
export ASAN_OPTIONS=detect_leaks=0
mkdir csmith_run && cd "$_"
bash ../scripts/run_csmith.bash $PWD/../slimcc_asan
59 changes: 59 additions & 0 deletions scripts/run_csmith.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
REFCC=clang

TSTCC=$1

EPOCH=$(date +"%s")

MAX_JOBS=4

csmith -v

for ((seed = EPOCH; seed <= $((EPOCH + 605000)); seed++)); do
if (( $(jobs -r -p | wc -l) >= MAX_JOBS )); then
wait -n
fi
(
if (( (seed % 5000) == 0 )); then
echo "heartbeat:"$seed
fi

mkdir -p $seed

csmith --no-packed-struct --seed $seed > $seed/main.c

cd $seed

$REFCC main.c -I /usr/include/csmith -lm -o ref.exe 2>/dev/null

timeout 1 ./ref.exe > ref.txt
if (( $? != 0 )); then
cd ../ && rm -r $seed
exit
fi

$TSTCC main.c -I /usr/include/csmith -lm -o tst.exe
if (( $? != 0 )); then
echo "tst cc failed at:"$seed
touch ../has_error
cd ../ && rm -r $seed
exit
fi

timeout 10 ./tst.exe > tst.txt

cmp -s ref.txt tst.txt
if (( $? != 0 )); then
echo "differ at:"$seed
touch ../has_error
fi

cd ../ && rm -r $seed
) &
done

wait

if test -f ./has_error; then
rm ./has_error
exit 1
fi

0 comments on commit 2530898

Please sign in to comment.