|
|
@ -17,6 +17,64 @@ function check_submodules() {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Takes two arguments:
|
|
|
|
|
|
|
|
# $1 arguments to pass to pgrep
|
|
|
|
|
|
|
|
# $2 process name to pgrep for
|
|
|
|
|
|
|
|
function gnuplot_wrapper() {
|
|
|
|
|
|
|
|
# inspired by https://gist.github.com/nicolasazrak/32d68ed6c845a095f75f037ecc2f0436
|
|
|
|
|
|
|
|
trap capture_ctrl_c INT
|
|
|
|
|
|
|
|
TEMP_DIR=$(mktemp --directory /tmp/tmp.koreaderXXX)
|
|
|
|
|
|
|
|
LOG="$TEMP_DIR/memory.log"
|
|
|
|
|
|
|
|
SCRIPT_PNG="$TEMP_DIR/script_png.p"
|
|
|
|
|
|
|
|
SCRIPT_SHOW="$TEMP_DIR/script_show.p"
|
|
|
|
|
|
|
|
IMAGE_PNG="$TEMP_DIR/graph.png"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "Memory plot output to $TEMP_DIR"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cat >"$SCRIPT_PNG" <<EOL
|
|
|
|
|
|
|
|
set term pngcairo size 1600,1200
|
|
|
|
|
|
|
|
set output "$IMAGE_PNG"
|
|
|
|
|
|
|
|
set ylabel "RSS"
|
|
|
|
|
|
|
|
set y2label "VSZ"
|
|
|
|
|
|
|
|
set ytics nomirror
|
|
|
|
|
|
|
|
set y2tics nomirror in
|
|
|
|
|
|
|
|
set yrange [0:*]
|
|
|
|
|
|
|
|
set y2range [0:*]
|
|
|
|
|
|
|
|
plot "$LOG" using 3 with lines axes x1y1 title "RSS", "$LOG" using 2 with lines axes x1y2 title "VSZ"
|
|
|
|
|
|
|
|
EOL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cat >"$SCRIPT_SHOW" <<EOL
|
|
|
|
|
|
|
|
set term wxt noraise
|
|
|
|
|
|
|
|
set ylabel "RSS"
|
|
|
|
|
|
|
|
set y2label "VSZ"
|
|
|
|
|
|
|
|
set ytics nomirror
|
|
|
|
|
|
|
|
set y2tics nomirror in
|
|
|
|
|
|
|
|
set yrange [0:*]
|
|
|
|
|
|
|
|
set y2range [0:*]
|
|
|
|
|
|
|
|
plot "$LOG" using 3 with lines axes x1y1 title "RSS", "$LOG" using 2 with lines axes x1y2 title "VSZ"
|
|
|
|
|
|
|
|
pause 1
|
|
|
|
|
|
|
|
reread
|
|
|
|
|
|
|
|
EOL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function capture_ctrl_c() {
|
|
|
|
|
|
|
|
kill "$LOOP_PID"
|
|
|
|
|
|
|
|
kill "$GNUPLOT_PID"
|
|
|
|
|
|
|
|
gnuplot "$SCRIPT_PNG"
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# initialize at 0 so gnuplot has something to show
|
|
|
|
|
|
|
|
echo "0 0 0" >"${LOG}"
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
|
|
|
ps -p "$(pgrep --delimiter ' ' $1 "$2")" -o pid=,vsz=,rss= >>"${LOG}"
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
done &
|
|
|
|
|
|
|
|
LOOP_PID=$!
|
|
|
|
|
|
|
|
gnuplot "$SCRIPT_SHOW" &
|
|
|
|
|
|
|
|
GNUPLOT_PID=$!
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function setup_env() {
|
|
|
|
function setup_env() {
|
|
|
|
files=$(ls -d ./koreader-emulator-*/koreader)
|
|
|
|
files=$(ls -d ./koreader-emulator-*/koreader)
|
|
|
|
assert_ret_zero $? "Emulator not found, please build it first."
|
|
|
|
assert_ret_zero $? "Emulator not found, please build it first."
|
|
|
@ -288,8 +346,7 @@ function kodev-wbuilder() {
|
|
|
|
echo "[*] Running wbuilder.lua..."
|
|
|
|
echo "[*] Running wbuilder.lua..."
|
|
|
|
pushd "${EMU_DIR}" && {
|
|
|
|
pushd "${EMU_DIR}" && {
|
|
|
|
EMULATE_READER_W=540 EMULATE_READER_H=720 ./luajit ./tools/wbuilder.lua
|
|
|
|
EMULATE_READER_W=540 EMULATE_READER_H=720 ./luajit ./tools/wbuilder.lua
|
|
|
|
} || exit
|
|
|
|
} && popd || exit
|
|
|
|
popd
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function kodev-run() {
|
|
|
|
function kodev-run() {
|
|
|
@ -305,6 +362,7 @@ OPTIONS:
|
|
|
|
--disable-touch use this if you want to simulate keyboard only devices
|
|
|
|
--disable-touch use this if you want to simulate keyboard only devices
|
|
|
|
-s=FOO --simulate=FOO simulate dimension and other specs for a given device model
|
|
|
|
-s=FOO --simulate=FOO simulate dimension and other specs for a given device model
|
|
|
|
supported model: kobo-aura-one, kindle3, hidpi
|
|
|
|
supported model: kobo-aura-one, kindle3, hidpi
|
|
|
|
|
|
|
|
--graph graph memory use (requires gnuplot)
|
|
|
|
"
|
|
|
|
"
|
|
|
|
screen_width=540
|
|
|
|
screen_width=540
|
|
|
|
screen_height=720
|
|
|
|
screen_height=720
|
|
|
@ -318,6 +376,9 @@ OPTIONS:
|
|
|
|
--no-build)
|
|
|
|
--no-build)
|
|
|
|
no_build=true
|
|
|
|
no_build=true
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
|
|
|
|
--graph)
|
|
|
|
|
|
|
|
graph_memory=true
|
|
|
|
|
|
|
|
;;
|
|
|
|
-w | --screen-width)
|
|
|
|
-w | --screen-width)
|
|
|
|
screen_width=${VALUE}
|
|
|
|
screen_width=${VALUE}
|
|
|
|
;;
|
|
|
|
;;
|
|
|
@ -374,6 +435,10 @@ OPTIONS:
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${graph_memory} ]; then
|
|
|
|
|
|
|
|
gnuplot_wrapper "--parent $$" "reader.lua"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "[*] Running KOReader with arguments: $*..."
|
|
|
|
echo "[*] Running KOReader with arguments: $*..."
|
|
|
|
pushd "${EMU_DIR}" && {
|
|
|
|
pushd "${EMU_DIR}" && {
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
@ -389,8 +454,11 @@ OPTIONS:
|
|
|
|
./reader.lua -d "$args"
|
|
|
|
./reader.lua -d "$args"
|
|
|
|
RETURN_VALUE=$?
|
|
|
|
RETURN_VALUE=$?
|
|
|
|
done
|
|
|
|
done
|
|
|
|
} || exit
|
|
|
|
} && popd || exit
|
|
|
|
popd
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${graph_memory} ]; then
|
|
|
|
|
|
|
|
capture_ctrl_c
|
|
|
|
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function kodev-test() {
|
|
|
|
function kodev-test() {
|
|
|
@ -407,6 +475,9 @@ OPTIONS:
|
|
|
|
PARAM=$(echo "$1" | awk -F= '{print $1}')
|
|
|
|
PARAM=$(echo "$1" | awk -F= '{print $1}')
|
|
|
|
VALUE=$(echo "$1" | awk -F= '{print $2}')
|
|
|
|
VALUE=$(echo "$1" | awk -F= '{print $2}')
|
|
|
|
case $PARAM in
|
|
|
|
case $PARAM in
|
|
|
|
|
|
|
|
--graph)
|
|
|
|
|
|
|
|
graph_memory=true
|
|
|
|
|
|
|
|
;;
|
|
|
|
--tags)
|
|
|
|
--tags)
|
|
|
|
opts="--tags=${VALUE}"
|
|
|
|
opts="--tags=${VALUE}"
|
|
|
|
;;
|
|
|
|
;;
|
|
|
@ -435,6 +506,7 @@ OPTIONS:
|
|
|
|
|
|
|
|
|
|
|
|
check_submodules && make
|
|
|
|
check_submodules && make
|
|
|
|
setup_env
|
|
|
|
setup_env
|
|
|
|
|
|
|
|
|
|
|
|
make "${EMU_DIR}/.busted"
|
|
|
|
make "${EMU_DIR}/.busted"
|
|
|
|
pushd "${EMU_DIR}" && {
|
|
|
|
pushd "${EMU_DIR}" && {
|
|
|
|
test_path="./spec/$1/unit"
|
|
|
|
test_path="./spec/$1/unit"
|
|
|
@ -450,8 +522,7 @@ OPTIONS:
|
|
|
|
--lazy \
|
|
|
|
--lazy \
|
|
|
|
-o "./spec/$1/unit/verbose_print" \
|
|
|
|
-o "./spec/$1/unit/verbose_print" \
|
|
|
|
--exclude-tags=notest "${test_path}"
|
|
|
|
--exclude-tags=notest "${test_path}"
|
|
|
|
} || exit
|
|
|
|
} && popd || exit
|
|
|
|
popd
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function kodev-cov() {
|
|
|
|
function kodev-cov() {
|
|
|
@ -514,8 +585,7 @@ OPTIONS:
|
|
|
|
+$((LUACOV_REPORT_SUMMARY - 1)) \
|
|
|
|
+$((LUACOV_REPORT_SUMMARY - 1)) \
|
|
|
|
luacov.report.out
|
|
|
|
luacov.report.out
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
} || exit
|
|
|
|
} && popd || exit
|
|
|
|
popd
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function kodev-log() {
|
|
|
|
function kodev-log() {
|
|
|
@ -609,8 +679,7 @@ case $1 in
|
|
|
|
kodev-build
|
|
|
|
kodev-build
|
|
|
|
pushd "${EMU_DIR}" && {
|
|
|
|
pushd "${EMU_DIR}" && {
|
|
|
|
./luajit -i setupkoenv.lua
|
|
|
|
./luajit -i setupkoenv.lua
|
|
|
|
} || exit
|
|
|
|
} && popd || exit
|
|
|
|
popd
|
|
|
|
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
log)
|
|
|
|
log)
|
|
|
|
shift 1
|
|
|
|
shift 1
|
|
|
|