functions.sh (c4bbe83d27c2446a033cc0381c3fb6be5e8c41c7) functions.sh (54ee3526796f56c249124686a33e1cc05f76ea21)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3# Copyright (C) 2018 Joe Lawrence <joe.lawrence@redhat.com>
4
5# Shell functions for the rest of the scripts.
6
7MAX_RETRIES=600
8RETRY_INTERVAL=".1" # seconds

--- 20 unchanged lines hidden (view full) ---

29function is_root() {
30 uid=$(id -u)
31 if [ $uid -ne 0 ]; then
32 echo "skip all tests: must be run as root" >&2
33 exit $ksft_skip
34 fi
35}
36
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3# Copyright (C) 2018 Joe Lawrence <joe.lawrence@redhat.com>
4
5# Shell functions for the rest of the scripts.
6
7MAX_RETRIES=600
8RETRY_INTERVAL=".1" # seconds

--- 20 unchanged lines hidden (view full) ---

29function is_root() {
30 uid=$(id -u)
31 if [ $uid -ne 0 ]; then
32 echo "skip all tests: must be run as root" >&2
33 exit $ksft_skip
34 fi
35}
36
37# Check if we can compile the modules before loading them
38function has_kdir() {
39 if [ -z "$KDIR" ]; then
40 KDIR="/lib/modules/$(uname -r)/build"
41 fi
42
43 if [ ! -d "$KDIR" ]; then
44 echo "skip all tests: KDIR ($KDIR) not available to compile modules."
45 exit $ksft_skip
46 fi
47}
48
37# die(msg) - game over, man
38# msg - dying words
39function die() {
40 log "ERROR: $1"
41 echo "ERROR: $1" >&2
42 exit 1
43}
44

--- 58 unchanged lines hidden (view full) ---

103}
104
105# setup_config - save the current config and set a script exit trap that
106# restores the original config. Setup the dynamic debug
107# for verbose livepatching output and turn on
108# the ftrace_enabled sysctl.
109function setup_config() {
110 is_root
49# die(msg) - game over, man
50# msg - dying words
51function die() {
52 log "ERROR: $1"
53 echo "ERROR: $1" >&2
54 exit 1
55}
56

--- 58 unchanged lines hidden (view full) ---

115}
116
117# setup_config - save the current config and set a script exit trap that
118# restores the original config. Setup the dynamic debug
119# for verbose livepatching output and turn on
120# the ftrace_enabled sysctl.
121function setup_config() {
122 is_root
123 has_kdir
111 push_config
112 set_dynamic_debug
113 set_ftrace_enabled 1
114 trap cleanup EXIT INT TERM HUP
115}
116
117# loop_until(cmd) - loop a command until it is successful or $MAX_RETRIES,
118# sleep $RETRY_INTERVAL between attempts

--- 218 unchanged lines hidden ---
124 push_config
125 set_dynamic_debug
126 set_ftrace_enabled 1
127 trap cleanup EXIT INT TERM HUP
128}
129
130# loop_until(cmd) - loop a command until it is successful or $MAX_RETRIES,
131# sleep $RETRY_INTERVAL between attempts

--- 218 unchanged lines hidden ---