File: fwupdmgr-online.sh

package info (click to toggle)
fwupd 2.0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,340 kB
  • sloc: ansic: 274,440; python: 11,468; xml: 9,432; sh: 1,625; makefile: 167; cpp: 19; asm: 11; javascript: 9
file content (240 lines) | stat: -rwxr-xr-x 5,165 bytes parent folder | download
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/sh

export NO_COLOR=1

exec 0>/dev/null
exec 2>&1

TMPDIR="$(mktemp -d)"
trap 'rm -rf -- "$TMPDIR"' EXIT

DEVICE=08d460be0f1f9f128413f816022a6439e0078018

error() {
    if [ -f "fwupd.txt" ]; then
        cat fwupd.txt
    else
        journalctl -u fwupd -b || true
    fi
    echo " ● exit code was ${1} and expected ${2}"
    exit 1
}

expect_rc() {
    rc=$?
    expected=$1

    [ "$expected" -eq "$rc" ] || error "$rc" "$expected"
}

if [ -z "$CI_NETWORK" ]; then
    echo " ● Skipping network tests due to CI_NETWORK not being set"
    exit 0
fi

# ---
echo " ● Verify test device is present"
fwupdmgr get-devices --json | jq -e '.Devices | any(.Plugin == "test")'
if [ $? != 0 ]; then
    echo " ● Skipping tests due to no test device enabled"
    exit 0
fi

# ---
echo " ● Resetting config…"
fwupdmgr reset-config test
expect_rc 0

# ---
echo " ● Downloading random file…"
fwupdmgr download https://cdn.fwupd.org/static/img/user-solid.svg --force
expect_rc 0

# ---
echo " ● Getting devices (should be one)…"
fwupdmgr get-devices --no-unreported-check
expect_rc 0

# ---
echo " ● Clean remote"
fwupdmgr clean-remote lvfs
expect_rc 0

# ---
echo " ● Showing remote ages (JSON)…"
fwupdmgr get-remotes lvfs --json
expect_rc 0

# ---
echo " ● Refreshing from the LVFS…"
fwupdmgr --download-retries=5 refresh --force
expect_rc 0
ls -R @localstatedir@/lib/fwupd/metadata/lvfs/firmware.xml.zst*
expect_rc 0

# ---
echo " ● Showing remote ages…"
fwupdmgr get-remotes lvfs
expect_rc 0

# ---
echo " ● Refreshing (already up to date)…"
cp @localstatedir@/lib/fwupd/metadata/lvfs/firmware.xml.zst* ${TMPDIR}
expect_rc 0
fwupdmgr refresh ${TMPDIR}/firmware.xml.zst ${TMPDIR}/firmware.xml.zst.jcat lvfs
expect_rc 2

# ---
echo " ● Sync BKC…"
fwupdmgr sync
expect_rc 2

# ---
echo " ● Check we can search for known tokens…"
fwupdmgr search CVE-2022-21894
expect_rc 0

# ---
echo " ● Check we do not find a random search result…"
fwupdmgr search DOESNOTEXIST
expect_rc 3

# ---
echo " ● Install a specific release…"
fwupdmgr --no-unreported-check --no-metadata-check --allow-reinstall --allow-older install ${DEVICE} 1.2.3
expect_rc 0

# ---
echo " ● Getting updates (should be one)…"
fwupdmgr --no-unreported-check --no-metadata-check get-updates
expect_rc 0

# ---
echo " ● Getting updates (should still be one)…"
fwupdmgr --no-unreported-check --no-metadata-check get-updates ${DEVICE}
expect_rc 0

# ---
echo " ● Installing test firmware…"
fwupdmgr update ${DEVICE} -y
expect_rc 0

# ---
echo " ● Update when not needed…"
fwupdmgr update ${DEVICE} -y
expect_rc 0

# ---
echo " ● Reinstall current release…"
fwupdmgr reinstall ${DEVICE} -y
expect_rc 0

# ---
echo " ● Switch branch of device (impossible)…"
fwupdmgr switch-branch ${DEVICE} impossible
expect_rc 1

# ---
echo " ● Activate device (not required)…"
fwupdmgr activate ${DEVICE}
expect_rc 2

# ---
echo " ● Getting history (should be one)…"
fwupdmgr get-history
expect_rc 0

# ---
echo " ● Getting history (JSON)…"
fwupdmgr get-history --json
expect_rc 0

# ---
echo " ● Exporting history…"
fwupdmgr report-export
expect_rc 0

# ---
echo " ● Check if anything was tagged for emulation"
fwupdmgr get-devices --json --filter emulation-tag | jq -e '(.Devices | length) > 0'
rc=$?
if [ $rc = 0 ]; then
    echo " ● Save device emulation"
    fwupdmgr emulation-save /dev/null
    expect_rc 0
    echo " ● Save device emulation (bad args)"
    fwupdmgr emulation-save
    expect_rc 1
fi

# ---
echo " ● Verifying results (str)…"
fwupdmgr get-results ${DEVICE} -y
expect_rc 0

# ---
echo " ● Verifying results (JSON)…"
fwupdmgr get-results ${DEVICE} -y --json
expect_rc 0

# ---
echo " ● Getting updates (should be none)…"
fwupdmgr --no-unreported-check --no-metadata-check get-updates
expect_rc 2

# ---
echo " ● Getting updates (JSON) (should be none)…"
fwupdmgr --no-unreported-check --no-metadata-check get-updates --json
expect_rc 0

# ---
echo " ● Updating verification…"
fwupdmgr verify-update ${DEVICE}
expect_rc 0

# ---
echo " ● Testing verification…"
fwupdmgr verify ${DEVICE}
expect_rc 0

# ---
echo " ● Downgrading to older release"
fwupdmgr --download-retries=5 downgrade ${DEVICE} -y
expect_rc 0

# ---
echo " ● Downgrading to older release (should be none)"
fwupdmgr downgrade ${DEVICE}
expect_rc 2

# ---
echo " ● Updating all devices to latest release"
fwupdmgr --download-retries=5 --no-unreported-check --no-metadata-check --no-reboot-check update -y
expect_rc 0

# ---
echo " ● Getting updates (should be none)…"
fwupdmgr --no-unreported-check --no-metadata-check get-updates
expect_rc 2

# ---
echo " ● Clearing results…"
fwupdmgr clear-results --json ${DEVICE}
expect_rc 0

# ---
echo " ● Check reboot behavior"
fwupdmgr modify-config test NeedsReboot true
expect_rc 0
fwupdmgr --no-unreported-check --no-metadata-check --allow-reinstall --allow-older install ${DEVICE} 1.2.3
expect_rc 0
fwupdmgr check-reboot-needed ${DEVICE} --json
expect_rc 0

# ---
echo " ● Resetting config…"
fwupdmgr reset-config test
expect_rc 0

# success!
exit 0