1
0
Fork 0

Adding upstream version 3.1.0+dfsg.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-05 08:00:08 +01:00
parent 64dbec996d
commit cfcebb1a7d
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
569 changed files with 205393 additions and 0 deletions

View file

@ -0,0 +1,8 @@
find_program(PATH_TCLSH NAMES tclsh)
if(NOT PATH_TCLSH)
message(WARNING "'tclsh' not found! The yangre test will not be available.")
else()
add_test(NAME "yangre" COMMAND "tclsh" "${CMAKE_CURRENT_SOURCE_DIR}/all.tcl")
set_property(TEST "yangre" APPEND PROPERTY ENVIRONMENT "TESTS_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
set_property(TEST "yangre" APPEND PROPERTY ENVIRONMENT "YANGRE=${PROJECT_BINARY_DIR}")
endif()

15
tests/yangre/all.tcl Normal file
View file

@ -0,0 +1,15 @@
package require tcltest
# Hook to determine if any of the tests failed.
# Sets a global variable exitCode to 1 if any test fails otherwise it is set to 0.
proc tcltest::cleanupTestsHook {} {
variable numTests
set ::exitCode [expr {$numTests(Failed) > 0}]
}
if {[info exists ::env(TESTS_DIR)]} {
tcltest::configure -testdir "$env(TESTS_DIR)"
}
tcltest::runAllTests
exit $exitCode

19
tests/yangre/arg.test Normal file
View file

@ -0,0 +1,19 @@
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/ly.tcl" : "ly.tcl"}]
test arg_empty {Missing arguments} {
ly_cmd_err "" "missing <string> parameter to process"
} {}
test arg_wrong {Wrong argument} {
ly_cmd_err "-j" "invalid option"
} {}
test arg_help {Print help} {
ly_cmd "-h" "Usage:"
} {}
test arg_version {Print version} {
ly_cmd "-v" "yangre"
} {}
cleanupTests

37
tests/yangre/file.test Normal file
View file

@ -0,0 +1,37 @@
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/ly.tcl" : "ly.tcl"}]
set fdir "$::env(TESTS_DIR)/files"
test file_empty {file is empty} {
ly_cmd "-f $fdir/empty.txt"
} {}
test file_empty_str {<string> is empty} {
ly_cmd "-f $fdir/empty_str.txt"
} {}
test file_empty_str_err {empty <string> is not allowed} {
ly_cmd_err "-f $fdir/empty_str_err.txt" "does not conform"
} {}
test file_one_pattern {one pattern in the file} {
ly_cmd "-f $fdir/one_pattern.txt"
} {}
test file_two_patterns {two patterns in the file} {
ly_cmd "-f $fdir/two_patterns.txt"
} {}
test file_two_patterns_err {two patterns and the <string> is wrong} {
ly_cmd_err "-f $fdir/two_patterns_err.txt" "does not conform"
} {}
test file_two_patterns_invert_match {one pattern is inverted} {
ly_cmd "-f $fdir/two_patterns_invert_match.txt"
} {}
test file_two_patterns_invert_match_err {one pattern is inverted and the <string> is wrong} {
ly_cmd_err "-f $fdir/two_patterns_invert_match_err.txt" "does not conform to inverted"
} {}
cleanupTests

View file

View file

@ -0,0 +1,2 @@
"[0-9a-fA-F]*"

View file

@ -0,0 +1,2 @@
"[0-9a-fA-F]+"

View file

@ -0,0 +1,3 @@
"[0-9a-fA-F]*"
1F

View file

@ -0,0 +1,4 @@
"[0-9a-fA-F]*"
'[a-zA-Z0-9\-_.]*'
1F

View file

@ -0,0 +1,4 @@
"[0-9a-fA-F]*"
'[a-zA-Z0-9\-_.]*'
@!@

View file

@ -0,0 +1,4 @@
"[a-z]*"
'[a-f]*'
gh

View file

@ -0,0 +1,4 @@
"[a-z]*"
'[a-f]*'
ab

View file

@ -0,0 +1,28 @@
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/ly.tcl" : "ly.tcl"}]
test invert_match_from_help1 {Test the first pattern from help via invert match} {
ly_cmd_err {-p {"[0-9a-fA-F]*"} -i {1F}} "not conform to inverted"
ly_cmd {-p {"[0-9a-fA-F]*"} -i {GUN}}
} {}
test invert_match_from_help2 {Test the second pattern from help via invert match} {
ly_cmd_err {-p {'[a-zA-Z0-9\-_.]*'} -i {a-b}} "not conform to inverted"
ly_cmd {-p {'[a-zA-Z0-9\-_.]*'} -i {%@}}
} {}
test invert_match_from_help3 {Test the third pattern from help via invert match} {
ly_cmd_err {-p {[xX][mM][lL].*} -i {xml-encoding}} "not conform to inverted"
ly_cmd {-p {[xX][mM][lL].*} -i {json}}
} {}
test invert_match_three_at_once {Test three inverted patterns and once} {
ly_cmd_err {-p {"[0-9a-zA-Z]*"} -i -p {'[a-zA-Z0-9\-_.]*'} -i -p {[xX][mM][lL].*} -i {xml}} "not conform to inverted"
ly_cmd {-p {"[0-9a-zA-Z]*"} -i -p {'[a-zA-Z0-9\-_.]*'} -i -p {[xX][mM][lL].*} -i {%@}}
} {}
test invert_match_second_is_not {Test three patterns but the second one is not inverted} {
ly_cmd_err {-p {"[0-9a-zA-Z]*"} -i -p {'[a-zA-Z0-9\-_.]*'} -i -p {[xX][mM][lL].*} -i {o_O}} "not conform to inverted"
ly_cmd {-p {"[0-9a-zA-Z]*"} -i -p {'[a-zA-Z0-9\-_.]*'} -p {[xX][mM][lL].*} -i {o_O}}
} {}
cleanupTests

17
tests/yangre/ly.tcl Normal file
View file

@ -0,0 +1,17 @@
# @brief The main source of functions and variables for testing yangre.
package require tcltest
namespace import ::tcltest::test ::tcltest::cleanupTests
if { ![info exists ::env(TESTS_DIR)] } {
# the script is not run via 'ctest' so paths must be set
set ::env(TESTS_DIR) "./"
set TUT_PATH "../../build"
} else {
# cmake (ctest) already sets ::env variables
set TUT_PATH $::env(YANGRE)
}
set TUT_NAME "yangre"
source "$::env(TESTS_DIR)/../tool_ni.tcl"
# The script continues by defining variables and functions specific to the yangre tool.

19
tests/yangre/pattern.test Normal file
View file

@ -0,0 +1,19 @@
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/ly.tcl" : "ly.tcl"}]
test pattern_from_help1 {Test the first pattern from help} {
ly_cmd {-p {"[0-9a-fA-F]*"} {1F}}
} {}
test pattern_from_help2 {Test the second pattern from help} {
ly_cmd {-p {'[a-zA-Z0-9\-_.]*'} {a-b}}
} {}
test pattern_from_help3 {Test the third pattern from help} {
ly_cmd {-p {[xX][mM][lL].*} {xml-encoding}}
} {}
test pattern_three_at_once {Test three patterns and once} {
ly_cmd {-p {"[0-9a-zA-Z]*"} -p {'[a-zA-Z0-9\-_.]*'} -p {[xX][mM][lL].*} {xml}}
} {}
cleanupTests