Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel_features: fix tests for new KernelConfig #58

Merged
merged 1 commit into from
Aug 29, 2021
Merged

kernel_features: fix tests for new KernelConfig #58

merged 1 commit into from
Aug 29, 2021

Conversation

rafaeldtinoco
Copy link
Contributor

This is a preparation for a fix for: aquasecurity/tracee#851

@rafaeldtinoco
Copy link
Contributor Author

This is the missing tests for the KernelConfig API we've discussed.

Copy link
Contributor

@grantseltzer grantseltzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these are failing for me:

[*] go test .                                                                                            
--- FAIL: TestGetKernelConfigValue (0.02s)
    --- FAIL: TestGetKernelConfigValue/multiple_options_ok (0.01s)
        kernel_features_test.go:75: 
            	Error Trace:	kernel_features_test.go:75
            	Error:      	Not equal: 
            	            	expected: 0x2
            	            	actual  : 0x0
            	Test:       	TestGetKernelConfigValue/multiple_options_ok
        kernel_features_test.go:76: 
            	Error Trace:	kernel_features_test.go:76
            	Error:      	Not equal: 
            	            	expected: <nil>(<nil>)
            	            	actual  : *errors.errorString(&errors.errorString{s:"given option's value (CONFIG_TEST_BPF) is undefined"})
            	Test:       	TestGetKernelConfigValue/multiple_options_ok
        kernel_features_test.go:75: 
            	Error Trace:	kernel_features_test.go:75
            	Error:      	Not equal: 
            	            	expected: 0x2
            	            	actual  : 0x0
            	Test:       	TestGetKernelConfigValue/multiple_options_ok
        kernel_features_test.go:76: 
            	Error Trace:	kernel_features_test.go:76
            	Error:      	Not equal: 
            	            	expected: <nil>(<nil>)
            	            	actual  : *errors.errorString(&errors.errorString{s:"given option's value (CONFIG_TEST_BPF) is undefined"})
            	Test:       	TestGetKernelConfigValue/multiple_options_ok
    --- FAIL: TestGetKernelConfigValue/string_value_ok (0.00s)
        kernel_features_test.go:75: 
            	Error Trace:	kernel_features_test.go:75
            	Error:      	Not equal: 
            	            	expected: "250"
            	            	actual  : "1000"
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1 +1 @@
            	            	-250
            	            	+1000
            	Test:       	TestGetKernelConfigValue/string_value_ok
        kernel_features_test.go:75: 
            	Error Trace:	kernel_features_test.go:75
            	Error:      	Not equal: 
            	            	expected: "250"
            	            	actual  : "1000"
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1 +1 @@
            	            	-250
            	            	+1000
            	Test:       	TestGetKernelConfigValue/string_value_ok
FAIL
FAIL	github.com/aquasecurity/libbpfgo/helpers	0.140s
FAIL

helpers/kernel_features.go Outdated Show resolved Hide resolved
@rafaeldtinoco
Copy link
Contributor Author

All good here using the files from the testdata directory:

/usr/lib/go-1.16/bin/go tool test2json -t /tmp/GoLand/___TestGetKernelConfigValue_in_github_com_aquasecurity_libbpfgo_helpers.test -test.v -test.paniconexit0 -test.run ^\QTestGetKernelConfigValue\E$
=== RUN   TestGetKernelConfigValue
=== RUN   TestGetKernelConfigValue/option_ok
=== RUN   TestGetKernelConfigValue/multiple_options_ok
=== RUN   TestGetKernelConfigValue/multiple_options_ok_with_single_not_ok
=== RUN   TestGetKernelConfigValue/multiple_options_ok_with_multiple_not_ok
=== RUN   TestGetKernelConfigValue/undefined_value
--- PASS: TestGetKernelConfigValue (0.00s)
    --- PASS: TestGetKernelConfigValue/option_ok (0.00s)
    --- PASS: TestGetKernelConfigValue/multiple_options_ok (0.00s)
    --- PASS: TestGetKernelConfigValue/multiple_options_ok_with_single_not_ok (0.00s)
    --- PASS: TestGetKernelConfigValue/multiple_options_ok_with_multiple_not_ok (0.00s)
    --- PASS: TestGetKernelConfigValue/undefined_value (0.00s)
PASS

@rafaeldtinoco rafaeldtinoco self-assigned this Aug 28, 2021
Copy link
Contributor

@grantseltzer grantseltzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :-)

@rafaeldtinoco rafaeldtinoco merged commit 7b38633 into aquasecurity:main Aug 29, 2021
@rafaeldtinoco rafaeldtinoco deleted the kconfigtests branch August 29, 2021 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants