1
+ using System ;
2
+ using BenchmarkDotNet . Helpers ;
3
+ using Xunit ;
4
+
5
+ namespace BenchmarkDotNet . Tests . Helpers
6
+ {
7
+ public class LinuxOsReleaseHelperTests
8
+ {
9
+ [ Theory ]
10
+ [ InlineData ( """
11
+ NAME="Ubuntu"
12
+ VERSION="20.04.1 LTS (Focal Fossa)"
13
+ ID=ubuntu
14
+ ID_LIKE=debian
15
+ PRETTY_NAME="Ubuntu 20.04.1 LTS"
16
+ VERSION_ID="20.04"
17
+ HOME_URL="https://www.ubuntu.com/"
18
+ SUPPORT_URL="https://help.ubuntu.com/"
19
+ BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
20
+ PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
21
+ VERSION_CODENAME=focal
22
+ UBUNTU_CODENAME=focal
23
+ """ , "Ubuntu 20.04.1 LTS (Focal Fossa)" ) ]
24
+ [ InlineData ( """
25
+ PRETTY_NAME="Debian GNU/Linux 10 (buster)"
26
+ NAME="Debian GNU/Linux"
27
+ VERSION_ID="10"
28
+ VERSION="10 (buster)"
29
+ VERSION_CODENAME=buster
30
+ ID=debian
31
+ HOME_URL="https://www.debian.org/"
32
+ SUPPORT_URL="https://www.debian.org/support"
33
+ BUG_REPORT_URL="https://bugs.debian.org/"
34
+ """ , "Debian GNU/Linux 10 (buster)" ) ]
35
+ [ InlineData ( """
36
+ NAME=Fedora
37
+ VERSION="32 (Thirty Two)"
38
+ ID=fedora
39
+ VERSION_ID=32
40
+ VERSION_CODENAME=""
41
+ PLATFORM_ID="platform:f32"
42
+ PRETTY_NAME="Fedora 32 (Thirty Two)"
43
+ ANSI_COLOR="0;34"
44
+ LOGO=fedora-logo-icon
45
+ CPE_NAME="cpe:/o:fedoraproject:fedora:32"
46
+ HOME_URL="https://fedoraproject.org/"
47
+ DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/"
48
+ SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
49
+ BUG_REPORT_URL="https://bugzilla.redhat.com/"
50
+ REDHAT_BUGZILLA_PRODUCT="Fedora"
51
+ REDHAT_BUGZILLA_PRODUCT_VERSION=32
52
+ REDHAT_SUPPORT_PRODUCT="Fedora"
53
+ REDHAT_SUPPORT_PRODUCT_VERSION=32
54
+ PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
55
+ """ , "Fedora 32 (Thirty Two)" ) ]
56
+ [ InlineData ( """
57
+ NAME="CentOS Linux"
58
+ VERSION="8 (Core)"
59
+ ID="centos"
60
+ ID_LIKE="rhel fedora"
61
+ VERSION_ID="8"
62
+ PLATFORM_ID="platform:el8"
63
+ PRETTY_NAME="CentOS Linux 8 (Core)"
64
+ ANSI_COLOR="0;31"
65
+ CPE_NAME="cpe:/o:centos:centos:8"
66
+ HOME_URL="https://www.centos.org/"
67
+ BUG_REPORT_URL="https://bugs.centos.org/"
68
+
69
+ CENTOS_MANTISBT_PROJECT="CentOS-8"
70
+ CENTOS_MANTISBT_PROJECT_VERSION="8"
71
+ REDHAT_SUPPORT_PRODUCT="centos"
72
+ REDHAT_SUPPORT_PRODUCT_VERSION="8"
73
+ """ , "CentOS Linux 8 (Core)" ) ]
74
+ [ InlineData ( """
75
+ NAME="Arch Linux"
76
+ PRETTY_NAME="Arch Linux"
77
+ ID=arch
78
+ BUILD_ID=rolling
79
+ ANSI_COLOR="38;2;23;147;209"
80
+ HOME_URL="https://archlinux.org/"
81
+ DOCUMENTATION_URL="https://wiki.archlinux.org/"
82
+ SUPPORT_URL="https://bbs.archlinux.org/"
83
+ BUG_REPORT_URL="https://bugs.archlinux.org/"
84
+ LOGO=archlinux
85
+ """ , "Arch Linux" ) ]
86
+ [ InlineData ( """
87
+ NAME="openSUSE Leap"
88
+ VERSION="15.2"
89
+ ID="opensuse-leap"
90
+ ID_LIKE="suse opensuse"
91
+ VERSION_ID="15.2"
92
+ PRETTY_NAME="openSUSE Leap 15.2"
93
+ ANSI_COLOR="0;32"
94
+ CPE_NAME="cpe:/o:opensuse:leap:15.2"
95
+ BUG_REPORT_URL="https://bugs.opensuse.org"
96
+ HOME_URL="https://www.opensuse.org/"
97
+ """ , "openSUSE Leap 15.2" ) ]
98
+ [ InlineData ( """
99
+ NAME="Manjaro Linux"
100
+ ID=manjaro
101
+ PRETTY_NAME="Manjaro Linux"
102
+ ANSI_COLOR="1;32"
103
+ HOME_URL="https://manjaro.org/"
104
+ SUPPORT_URL="https://manjaro.org/"
105
+ BUG_REPORT_URL="https://bugs.manjaro.org/"
106
+ LOGO=manjarolinux
107
+ """ , "Manjaro Linux" ) ]
108
+ [ InlineData ( """
109
+ NAME="Linux Mint"
110
+ VERSION="20 (Ulyana)"
111
+ ID=linuxmint
112
+ ID_LIKE=ubuntu
113
+ PRETTY_NAME="Linux Mint 20"
114
+ VERSION_ID="20"
115
+ HOME_URL="https://www.linuxmint.com/"
116
+ SUPPORT_URL="https://forums.linuxmint.com/"
117
+ BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
118
+ PRIVACY_POLICY_URL="https://www.linuxmint.com/"
119
+ VERSION_CODENAME=ulyana
120
+ UBUNTU_CODENAME=focal
121
+ """ , "Linux Mint 20 (Ulyana)" ) ]
122
+ [ InlineData ( """
123
+ NAME="Alpine Linux"
124
+ ID=alpine
125
+ VERSION_ID=3.12.0
126
+ PRETTY_NAME="Alpine Linux v3.12"
127
+ HOME_URL="https://alpinelinux.org/"
128
+ BUG_REPORT_URL="https://bugs.alpinelinux.org/"
129
+ """ , "Alpine Linux v3.12" ) ]
130
+ [ InlineData ( """
131
+ NAME="Solus"
132
+ VERSION="4.1"
133
+ ID="solus"
134
+ PRETTY_NAME="Solus"
135
+ ANSI_COLOR="1;34"
136
+ HOME_URL="https://getsol.us"
137
+ SUPPORT_URL="https://getsol.us/articles/contributing/getting-involved/en/"
138
+ BUG_REPORT_URL="https://dev.getsol.us/"
139
+ """ , "Solus 4.1" ) ]
140
+ [ InlineData ( """
141
+ NAME="Red Hat Enterprise Linux"
142
+ VERSION="8.2 (Ootpa)"
143
+ ID="rhel"
144
+ ID_LIKE="fedora"
145
+ VERSION_ID="8.2"
146
+ PLATFORM_ID="platform:el8"
147
+ PRETTY_NAME="Red Hat Enterprise Linux 8.2 (Ootpa)"
148
+ ANSI_COLOR="0;31"
149
+ CPE_NAME="cpe:/o:redhat:enterprise_linux:8.2:GA"
150
+ HOME_URL="https://www.redhat.com/"
151
+ BUG_REPORT_URL="https://bugzilla.redhat.com/"
152
+ REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
153
+ REDHAT_BUGZILLA_PRODUCT_VERSION=8.2
154
+ REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
155
+ REDHAT_SUPPORT_PRODUCT_VERSION="8.2"
156
+ """ , "Red Hat Enterprise Linux 8.2 (Ootpa)" ) ]
157
+ [ InlineData ( """
158
+ PRETTY_NAME="Kali GNU/Linux Rolling"
159
+ NAME="Kali GNU/Linux"
160
+ ID=kali
161
+ VERSION="2020.2"
162
+ VERSION_ID="2020.2"
163
+ VERSION_CODENAME="kali-rolling"
164
+ ID_LIKE=debian
165
+ ANSI_COLOR="1;31"
166
+ HOME_URL="https://www.kali.org/"
167
+ SUPPORT_URL="https://forums.kali.org/"
168
+ BUG_REPORT_URL="https://bugs.kali.org/"
169
+ """ , "Kali GNU/Linux 2020.2" ) ]
170
+ [ InlineData ( """
171
+ NAME="elementary OS"
172
+ VERSION="5.1.7 Hera"
173
+ ID=elementary
174
+ ID_LIKE=ubuntu
175
+ PRETTY_NAME="elementary OS 5.1.7 Hera"
176
+ LOGO=distributor-logo
177
+ VERSION_ID="5.1.7"
178
+ HOME_URL="https://elementary.io/"
179
+ SUPPORT_URL="https://elementary.io/support"
180
+ BUG_REPORT_URL="https://github.com/elementary/os/issues/new"
181
+ PRIVACY_POLICY_URL="https://elementary.io/privacy-policy"
182
+ VERSION_CODENAME=hera
183
+ UBUNTU_CODENAME=bionic
184
+ """ , "elementary OS 5.1.7 Hera" ) ]
185
+ [ InlineData ( """
186
+ NAME="Zorin OS"
187
+ VERSION="15.2"
188
+ ID=zorin
189
+ ID_LIKE=ubuntu
190
+ PRETTY_NAME="Zorin OS 15.2"
191
+ VERSION_ID="15"
192
+ HOME_URL="https://www.zorinos.com/"
193
+ SUPPORT_URL="https://www.zorinos.com/help"
194
+ BUG_REPORT_URL="https://www.zorinos.com/contact"
195
+ PRIVACY_POLICY_URL="https://www.zorinos.com/legal/privacy"
196
+ VERSION_CODENAME=bionic
197
+ UBUNTU_CODENAME=bionic
198
+ """ , "Zorin OS 15.2" ) ]
199
+ public void LinuxOsReleaseHelperTest ( string osReleaseContent , string expectedName )
200
+ {
201
+ string [ ] lines = osReleaseContent . Split ( new [ ] { '\r ' , '\n ' } , StringSplitOptions . RemoveEmptyEntries ) ;
202
+ string actualName = LinuxOsReleaseHelper . GetNameByOsRelease ( lines ) ;
203
+ Assert . Equal ( expectedName , actualName ) ;
204
+ }
205
+ }
206
+ }
0 commit comments