interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / tests / dagsim / mutant_lifetime.sh

37 lines · 2190 bytes Raw Blame History
1#!/bin/sh
2# Drop the inverted-lifetime check and require the named assertion to fail.
3# A mutant that still prints a passing inverted_lifetime_masks_overflow is a miss.
4set -eu
5ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
6cd "$ROOT"
7src=tools/dagsim/dagsim.c
8grep -q 'LIFETIME_ORDER_CHECK' "$src"
9tmp=$(mktemp -d)
10trap 'rm -rf "$tmp"' EXIT
11sed '/LIFETIME_ORDER_CHECK/d' "$src" > "$tmp/dagsim.c"
12grep -q 'LIFETIME_ORDER_CHECK' "$tmp/dagsim.c" && { echo "mutant: check still present"; exit 1; }
13grep -q 'reject_inverted_lifetimes' "$tmp/dagsim.c" || { echo "mutant: deleted more than the call"; exit 1; }
14
15CC=${CC:-cc}
16# -Wno-unused-function: deleting the call leaves reject_inverted_lifetimes unreferenced.
17# The mutant has to run. The kill is the named assertion, not a compile error.
18cflags="-std=gnu11 -Wall -Wextra -Werror -Wno-unused-function -D_GNU_SOURCE -O2 -ffp-contract=off -DCUDAPP_MIGRATION_PENDING_C_TOOLS -DCUDAPP_MIGRATION_PENDING_C_DAGSIM_RESOLVE=1 -Isrc -Itools/dagsim"
19$CC $cflags -c -o "$tmp/dagsim.o" "$tmp/dagsim.c"
20$CC $cflags -ffp-contract=off -c -o "$tmp/rx_costmodel.o" src/runtime/rx_costmodel.c
21# CUDA++ has no src/omega_om_units.c; src/sha256.c is sha256_hash on every host and calls the core_sha unit (Makefile DS_SHA_SRC).
22sha=src/sha256.c
23$CC $cflags -o "$tmp/unit" tests/dagsim/dagsim_unit.c "$tmp/dagsim.o" "$tmp/rx_costmodel.o" "$sha" src/cudapp_om_core_sha.c src/cudapp_om_cm_sort.c src/cudapp_om_cm_math.c src/cudapp_om_cm_fit.c src/cudapp_om_cm_stats.c src/cudapp_om_cm_features.c src/cudapp_om_cm_quantile.c src/cudapp_om_cm_decision.c src/cudapp_om_cm_prediction.c src/cudapp_om_cm_calibration.c src/cudapp_om_cm_blob.c src/cudapp_om_cm_digest.c src/cudapp_om_cm_route.c src/cudapp_om_dag_parse.c src/cudapp_om_dag_fmt.c -Wl,--wrap=rx_cm_predict -lm
24set +e
25"$tmp/unit" > "$tmp/out" 2>&1
26rc=$?
27set -e
28if [ "$rc" -eq 0 ]; then
29 echo "mutant survived: unit suite passed after dropping LIFETIME_ORDER_CHECK"
30 exit 1
31fi
32if ! grep -q 'inverted_lifetime_masks_overflow' "$tmp/out"; then
33 echo "mutant did not fail named assertion inverted_lifetime_masks_overflow"
34 cat "$tmp/out"
35 exit 1
36fi
37echo "mutant killed: inverted_lifetime_masks_overflow"