OILS / test / ltrace.sh View on Github | oilshell.org

50 lines, 28 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# test/ltrace.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10source devtools/run-task.sh
11source test/common.sh # log
12
13BASE_DIR=_tmp/ltrace
14
15test-home-dir() {
16
17 mkdir -p $BASE_DIR
18
19 # ltrace doesn't work with ASAN, etc.
20 local osh=_bin/cxx-dbg/osh
21 ninja $osh
22
23 local status=0
24
25 # zsh calls getpwuid
26 # bash on my Ubuntu machine doesn't call it, but seems to in the Debian CI
27 # image
28 # could test mksh, but it's not in the CI image
29 for sh in $osh dash "$@"; do
30 local trace
31 trace=$BASE_DIR/$(basename $sh).txt
32
33 set -x
34 ltrace -e getpwuid -- $sh -c 'echo hi' 2> $trace
35 set +x
36
37 if grep getpwuid $trace; then
38 log "ERROR: $sh should not call getpwuid()"
39 status=1
40 fi
41 done
42
43 return $status
44}
45
46soil-run() {
47 test-home-dir
48}
49
50run-task "$@"