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

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