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 / tools / runtime / fresh-checkout-hello.sh

38 lines · 2274 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# fresh-checkout-hello.sh <branch> [log-file]
4# Proves the README's "Run your first kernel" works from nothing: clones <branch> from GitHub into an
5# empty temporary folder, takes the commands from that section of the README (the first bash block), runs
6# only those, and records the output with the commit it ran. Exit code is that of the first README command
7# that fails (0 when all pass). This is a correctness check, not a timing run. It runs as the current user
8# with the current environment; tools/runtime/clean-user-hello.sh is the stricter run as a brand-new user.
9# It uses the GPU, so run it under the shared lock: flock -w 900 /tmp/aien-gb10.lock <this script> <branch> <log>
10set -uo pipefail
11branch=${1:?usage: fresh-checkout-hello.sh <branch> [log-file]}
12log=${2:-/dev/stdout}
13url=${CUDAPP_URL:-https://github.com/aien-dev/CUDApp}
14work=$(mktemp -d "${TMPDIR:-/tmp}/cudapp-fresh.XXXXXX")
15cleanup() { rm -rf "$work"; }
16trap cleanup EXIT
17{
18 echo "# fresh-checkout-hello: branch=$branch url=$url"
19 echo "# date: $(date -u +%FT%TZ) host: $(uname -srm) work: $work"
20 # the README commands come from the pushed branch itself
21 git clone -q --branch "$branch" "$url" "$work/src.readme" 2>&1 || { echo "FAIL: cannot clone $branch"; exit 3; }
22 cmds=$(awk '/^## Run your first kernel/{s=1;next} s&&/^```bash/{b=1;next} s&&b&&/^```/{exit} s&&b{print}' "$work/src.readme/README.md")
23 [ -n "$cmds" ] || { echo "FAIL: no bash block under 'Run your first kernel' in README.md"; exit 3; }
24 echo "# README commands:"; echo "$cmds" | sed 's/^/# /'
25 rm -rf "$work/src.readme"
26 # run them in a clean folder; the clone line is pointed at the branch under test
27 mkdir "$work/run" && cd "$work/run" || exit 3
28 cmds=$(echo "$cmds" | sed -E "s#^git clone #git clone --branch $branch #; s#https://github.com/aien-dev/CUDApp([^A-Za-z0-9_.-]|\$)#$url\\1#")
29 rc=0
30 while IFS= read -r line; do
31 [ -n "$line" ] || continue
32 echo "\$ $line"
33 bash -c "$line" 2>&1 || { rc=$?; echo "# command exited $rc"; break; }
34 case $line in "cd "*) cd "${line#cd }" || exit 3; echo "# commit: $(git rev-parse HEAD)";; esac
35 done <<<"$cmds"
36 echo "# fresh-checkout-hello exit code: $rc"
37 exit $rc
38} > >(tee "$log") 2>&1