go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/kernel/info_test.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package kernel 5 6 import ( 7 "github.com/stretchr/testify/assert" 8 "github.com/stretchr/testify/require" 9 "strings" 10 "testing" 11 ) 12 13 func TestParseLinuxKernelArguments(t *testing.T) { 14 // testing output of /proc/cmdline 15 16 output := "BOOT_IMAGE=/boot/vmlinuz-3.10.0-1127.19.1.el7.x86_64 root=UUID=ff6cbb65-ccab-489c-91a5-61b9b09e4d49 ro crashkernel=auto console=ttyS0,38400n8 elevator=noop\n" 17 args, err := ParseLinuxKernelArguments(strings.NewReader(output)) 18 require.NoError(t, err) 19 assert.Equal(t, "/boot/vmlinuz-3.10.0-1127.19.1.el7.x86_64", args.Path) 20 assert.Equal(t, "UUID=ff6cbb65-ccab-489c-91a5-61b9b09e4d49", args.Device) 21 assert.Equal(t, map[string]string{"console": "ttyS0,38400n8", "crashkernel": "auto", "elevator": "noop", "ro": ""}, args.Arguments) 22 23 output = "earlyprintk=serial console=ttyS0 console=ttyS1 page_poison=1 vsyscall=emulate panic=1 nospec_store_bypass_disable noibrs noibpb no_stf_barrier mitigations=off\n" 24 args, err = ParseLinuxKernelArguments(strings.NewReader(output)) 25 require.NoError(t, err) 26 assert.Equal(t, "", args.Path) 27 assert.Equal(t, "", args.Device) 28 assert.Equal(t, map[string]string{"console": "ttyS1", "earlyprintk": "serial", "mitigations": "off", "no_stf_barrier": "", "noibpb": "", "noibrs": "", "nospec_store_bypass_disable": "", "page_poison": "1", "panic": "1", "vsyscall": "emulate"}, args.Arguments) 29 }