mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 19:18:19 +00:00
Reorganizing btest/policy directory to match new scripts/ organization
Addresses #545
This commit is contained in:
parent
2eea193d79
commit
c3fb0ea035
134 changed files with 2 additions and 2 deletions
58
testing/btest/scripts/base/utils/paths.test
Normal file
58
testing/btest/scripts/base/utils/paths.test
Normal file
|
@ -0,0 +1,58 @@
|
|||
# @TEST-EXEC: bro %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
# This is loaded by default.
|
||||
#@load base/utils/paths
|
||||
|
||||
function test_extract(str: string, expect: string)
|
||||
{
|
||||
local result = extract_path(str);
|
||||
print fmt("Given : %s", str);
|
||||
print fmt("Expect: %s", expect);
|
||||
print fmt("Result: %s", result);
|
||||
print fmt("Result: %s", result == expect ? "SUCCESS" : "FAIL");
|
||||
print "===============================";
|
||||
}
|
||||
|
||||
function test_compress(str: string, expect: string)
|
||||
{
|
||||
local result = compress_path(str);
|
||||
print fmt("Given : %s", str);
|
||||
print fmt("Expect: %s", expect);
|
||||
print fmt("Result: %s", result);
|
||||
print fmt("Result: %s", result == expect ? "SUCCESS" : "FAIL");
|
||||
print "===============================";
|
||||
}
|
||||
|
||||
print "test compress_path()";
|
||||
print "===============================";
|
||||
test_compress("foo//bar", "foo/bar");
|
||||
test_compress("foo//bar/..", "foo");
|
||||
test_compress("foo/bar/../..", "");
|
||||
test_compress("foo//bar/../..", "");
|
||||
test_compress("/foo/../bar", "/bar");
|
||||
test_compress("/foo/../bar/..", "/");
|
||||
test_compress("/foo/baz/../..", "/");
|
||||
test_compress("../..", "../..");
|
||||
test_compress("foo/../../..", "../..");
|
||||
|
||||
print "test extract_path()";
|
||||
print "===============================";
|
||||
test_extract("\"/this/is/a/dir\" is current directory", "/this/is/a/dir");
|
||||
test_extract("/this/is/a/dir is current directory", "/this/is/a/dir");
|
||||
test_extract("/this/is/a/dir\\ is\\ current\\ directory", "/this/is/a/dir\\ is\\ current\\ directory");
|
||||
test_extract("hey, /foo/bar/baz.bro is a cool script", "/foo/bar/baz.bro");
|
||||
test_extract("here's two dirs: /foo/bar and /foo/baz", "/foo/bar");
|
||||
|
||||
print "test build_path_compressed()";
|
||||
print "===============================";
|
||||
print build_path_compressed("/home/bro/", "policy/somefile.bro");
|
||||
print build_path_compressed("/home/bro/", "/usr/local/bro/share/bro/somefile.bro");
|
||||
print build_path_compressed("/home/bro/", "/usr/local/bro/share/../../bro/somefile.bro");
|
||||
|
||||
print "===============================";
|
||||
print "test build_full_path()";
|
||||
print "===============================";
|
||||
print build_path("/home/bro/", "policy/somefile.bro");
|
||||
print build_path("/home/bro/", "/usr/local/bro/share/bro/somefile.bro");
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue