File: smoke

package info (click to toggle)
libubootenv 0.3.5-0.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 348 kB
  • sloc: ansic: 2,024; sh: 22; makefile: 9
file content (44 lines) | stat: -rwxr-xr-x 1,198 bytes parent folder | download | duplicates (5)
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
#!/bin/sh
set -e
set -u

# create a temporary working directory
WORKDIR="$(mktemp -d)"
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd "$WORKDIR"

# create a config file
echo "$WORKDIR/test.img 0x0 0x2000" > fw_env.config

# create the test image file which will hold our environment
touch test.img

# create initial environment from empty default (/dev/null).
# redirect stderr message: Cannot read environment, using default
fw_setenv -c ./fw_env.config -f /dev/null foo bar 2>&1

# write more values to the environment
fw_setenv -c ./fw_env.config lala baba
fw_setenv -c ./fw_env.config apa bepa

# read back values and verify results.

## verify we have 3 rows in total.
ENVROWS="$(fw_printenv -c ./fw_env.config | wc -l)"
if [ "$ENVROWS" != 3 ]; then
	echo "Error: expected 3 values in env, but found '$ENVROWS'." >&2
fi

## verify the key foo has value bar
FOO="$(fw_printenv -c ./fw_env.config foo)"
if [ "$FOO" != "foo=bar" ]; then
	echo "Error: expected foo=bar, but got '$FOO'." >&2
fi

## verify only fetching value of lala returns baba.
LALA="$(fw_printenv -c ./fw_env.config -n lala)"
if [ "$LALA" != "baba" ]; then
	echo "Error: reading lala expected baba, got '$LALA'." >&2
fi