aboutsummaryrefslogtreecommitdiff
path: root/luajit-aarch64/builders.sh
blob: a410e513c7881264733d6e04d16eb44648f24300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash

set -ex

########## Helper functions ##########

# Message prefix
_msg_prefix () {
  echo "[$(date +%H:%M:%S)]$(hostname):"
}

# Report a message
msg () {
  echo "$(_msg_prefix):MSG: $*"
}

# Report an error and terminate the script
err () {
  echo "$(_msg_prefix):ERR: $*"
  exit 1
}

# Verbose-debug message
dbg () {
  # Don't print debug message if CI_DEBUG is 'false'.
  if [ "$CI_DEBUG" = "false" ]; then
    return
  fi
  echo "$(_msg_prefix):DBG: $*"
}

# run [command] [args ...]
run () {
  dbg Running : "$@"
  "$@"
}

# 'safe [command]' executes [command] and terminates if the exit code is
# nonzero. An alternative to "set -e"
safe () {
  run "$@"
  local err_num=$?
  if [ $err_num -ne 0 ]; then
    err "Error [$err_num] while doing [$*]"
  fi
}

# Suggested number of parallel tasks
njobs () {
  local cpus=$(nproc)
  if [ $cpus -le 1 ]; then
    echo 1
  else
    echo $(($cpus - 1))
  fi
}

########## LuaJIT build and test ##########

arch=$(uname -m)

case $arch in
x86_64)
	arch=x86
	;;
armv71)
	arch=arm
	;;
aarch64)
	arch=arm64
	;;
*)
	err "No nodes to build for this architecture ($arch)"
	;;
esac

# Build and install
THISBUILDDIR="${WORKSPACE}/build${BUILD_NUMBER}"
safe mkdir -p "$THISBUILDDIR"/dump
safe make CCDEBUG="-DUSE_LUA_ASSERT" PREFIX="$THISBUILDDIR"/install install -j "$(njobs)"
safe ln -sf "$THISBUILDDIR"/install/bin/luajit-* "$THISBUILDDIR"/install/bin/luajit
safe export LUA_PATH="$(ls -d "$THISBUILDDIR"/install/share/luajit*)/?.lua;;"
# Run a simple test
safe ./src/luajit -jdump -e "x=0; for i=1,100 do x=x+i end; print(x)"

TESTSUITE_GIT_URL=https://github.com/SameeraDes/LuaJIT-test-cleanup.git

safe cd $THISBUILDDIR
safe git clone $TESTSUITE_GIT_URL LuaJIT-testsuite
safe cd LuaJIT-testsuite/test
safe "$THISBUILDDIR"/install/bin/luajit test.lua

safe cd $THISBUILDDIR/LuaJIT-testsuite/bench

while IFS=" " read -r bench opts rest; do
	if [[ "$rest" = "" ]] ; then
		x=`{ time "$THISBUILDDIR"/install/bin/luajit  $bench.lua $opts > "$THISBUILDDIR"/dump/perf_$bench.dmp ; } 2>&1 | grep "real" | cut -f 2`
	else
		x=`{ time "$THISBUILDDIR"/install/bin/luajit  $bench.lua $opts < $rest > "$THISBUILDDIR"/dump/perf_$bench.dmp ; } 2>&1 | grep "real" | cut -f 2`
	fi
	echo $bench": " $x
done < PARAM_${arch}.txt > "$THISBUILDDIR"/dump/bench.txt

safe cat "$THISBUILDDIR"/dump/bench.txt
rm $THISBUILDDIR -rf

### Additional internal test which doesn't exist everywhere
##if make -n test > /dev/null; then
##  safe make test
##fi