summaryrefslogtreecommitdiff
path: root/backport-Add-a-test-for-special-device-node-installation.patch
blob: 8fd8ff996272fc6dc07f5dbb27db1931880a9c5d (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
From 5dcc399cd21f607f13eb092a3abfc8b8daa59d4c Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Fri, 13 Jan 2023 10:44:28 +0200
Subject: [PATCH] Add a test for special device node installation

This is a bit theoretical as it does not work for regular users or in
containers which are the typical scenarios for running the test-suite.
---
 tests/atlocal.in          |  6 ++++++
 tests/data/SPECS/dev.spec | 14 ++++++++++++++
 tests/rpmi.at             | 17 +++++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 tests/data/SPECS/dev.spec

diff --git a/tests/atlocal.in b/tests/atlocal.in
index c3189d3..1fb08d4 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -49,6 +49,12 @@ if grep -q '#define WITH_CAP 1' "${abs_top_builddir}/config.h"; then
 else
     CAP_DISABLED=true;
 fi
+if mknod foodev c 123 123; then
+   MKNOD_DISABLED=false
+   rm -f foodev
+else
+   MKNOD_DISABLED=true
+fi
 
 function setup_env()
 {
diff --git a/tests/data/SPECS/dev.spec b/tests/data/SPECS/dev.spec
new file mode 100644
index 000000000..d784fe114
--- /dev/null
+++ b/tests/data/SPECS/dev.spec
@@ -0,0 +1,14 @@
+Name: dev
+Version: 1.0
+Release: 1
+Group: Testing
+License: GPL
+Summary: Testing dev behavior
+BuildArch: noarch
+
+%description
+%{summary}
+
+%files
+%dev(c 11 22) /test-char
+%dev(b 33 44) /test-block
diff --git a/tests/rpmi.at b/tests/rpmi.at
index a2389de..f439e46 100644
--- a/tests/rpmi.at
+++ b/tests/rpmi.at
@@ -888,3 +888,20 @@ runroot rpm -Vv --nouser --nogroup fifo
 ],
 [])
 AT_CLEANUP
+
+AT_SETUP([rpm -U dev])
+AT_KEYWORDS([install])
+AT_SKIP_IF([$MKNOD_DISABLED])
+AT_CHECK([
+RPMDB_INIT
+
+runroot rpmbuild -bb --quiet /data/SPECS/dev.spec
+runroot rpm -U --ignoreos /build/RPMS/noarch/dev-1.0-1.noarch.rpm
+runroot rpm -Vv --nouser --nogroup dev
+],
+[0],
+[.........    /test-block
+.........    /test-char
+],
+[])
+AT_CLEANUP
-- 
2.27.0