feat(L01): add BusyBox multicall console card
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
action="${1:?action is required}"
|
||||
root="${STEM_REPO:-${CARD_ROOT:-$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)}}"
|
||||
profile="${STEM_PROFILE:-native-amd64}"
|
||||
target="${STEM_TARGET:-native}"
|
||||
selector="${STEM_TASK:-task1}"
|
||||
tasks=(task01_multicall_dispatch task02_files_and_text task03_process_and_host)
|
||||
resolve_task() {
|
||||
local value="${1,,}" task_name
|
||||
for task_name in "${tasks[@]}"; do [[ "$value" == "$task_name" ]] && { printf '%s\n' "$task_name"; return; }; done
|
||||
[[ "$value" =~ ^(task|t)?[-_]?0*([1-3])($|[-_].*) ]] && { printf '%s\n' "${tasks[${BASH_REMATCH[2]} - 1]}"; return; }
|
||||
printf 'Unknown task selector: %s\n' "$1" >&2; exit 2
|
||||
}
|
||||
task="$(resolve_task "$selector")"
|
||||
artifact_dir="$root/.stem/artifacts/$profile/$target/$task"
|
||||
mkdir -p "$artifact_dir"
|
||||
case "$profile:$target:$action" in
|
||||
native-amd64:native:build)
|
||||
bash -n "$root"/src/tasks/*.sh "$root/tests/test_tasks.sh"
|
||||
cc -std=c11 -Wall -Wextra -Werror -fsyntax-only "$root/src/fixtures/multicall_lab.c"
|
||||
printf 'BUILD tasks=3 fixture=multicall_lab.c\n'
|
||||
;;
|
||||
native-amd64:native:test|native-amd64:native:run)
|
||||
exec env CARD_ROOT="$root" "$root/tests/test_tasks.sh" "$task"
|
||||
;;
|
||||
native-amd64:native:debug)
|
||||
trace_file="$artifact_dir/trace.log"
|
||||
set +e
|
||||
env CARD_ROOT="$root" bash -x "$root/tests/test_tasks.sh" "$task" >"$trace_file" 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
cat "$trace_file"
|
||||
[[ $status -eq 0 && -s "$trace_file" ]]
|
||||
printf 'TRACE %s log=%s\n' "$task" "$trace_file"
|
||||
;;
|
||||
*) printf 'Unsupported profile/target/action: %s/%s/%s\n' "$profile" "$target" "$action" >&2; exit 2 ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user