From: Karel Zak Date: Mon, 20 Nov 2023 21:15:31 +0000 (+0100) Subject: tests: add libsmartcols filter tests X-Git-Tag: v2.40-rc1~151^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b208ed680c64198f2f19ba760fc5529671132d38;p=thirdparty%2Futil-linux.git tests: add libsmartcols filter tests Signed-off-by: Karel Zak --- diff --git a/tests/expected/libsmartcols/filter b/tests/expected/libsmartcols/filter new file mode 100644 index 0000000000..4155aa36f5 --- /dev/null +++ b/tests/expected/libsmartcols/filter @@ -0,0 +1 @@ +...done. diff --git a/tests/expected/libsmartcols/filter-bool-and b/tests/expected/libsmartcols/filter-bool-and new file mode 100644 index 0000000000..136149c530 --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-and @@ -0,0 +1,7 @@ +expr: BOOL && NAME + +NAME BOOL +bbb 1 +ee true +hhh TRUE +jj 1 diff --git a/tests/expected/libsmartcols/filter-bool-as-string b/tests/expected/libsmartcols/filter-bool-as-string new file mode 100644 index 0000000000..213ce5893c --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-as-string @@ -0,0 +1,2 @@ +expr: BOOL == "0" + diff --git a/tests/expected/libsmartcols/filter-bool-as-string2 b/tests/expected/libsmartcols/filter-bool-as-string2 new file mode 100644 index 0000000000..c4ddd20198 --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-as-string2 @@ -0,0 +1,2 @@ +expr: BOOL == "1" + diff --git a/tests/expected/libsmartcols/filter-bool-eq-false b/tests/expected/libsmartcols/filter-bool-eq-false new file mode 100644 index 0000000000..8454205178 --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-eq-false @@ -0,0 +1,8 @@ +expr: BOOL == FALSE + +NAME BOOL +aaaa 0 +dddddd 0 +ffff false +gggggg FALSE +iiiiii 0 diff --git a/tests/expected/libsmartcols/filter-bool-eq-false2 b/tests/expected/libsmartcols/filter-bool-eq-false2 new file mode 100644 index 0000000000..d0d19ff55e --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-eq-false2 @@ -0,0 +1,8 @@ +expr: BOOL == false + +NAME BOOL +aaaa 0 +dddddd 0 +ffff false +gggggg FALSE +iiiiii 0 diff --git a/tests/expected/libsmartcols/filter-bool-eq-false3 b/tests/expected/libsmartcols/filter-bool-eq-false3 new file mode 100644 index 0000000000..605bc932b9 --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-eq-false3 @@ -0,0 +1,9 @@ +expr: BOOL == 0 + +NAME BOOL +aaaa 0 +ccccc +dddddd 0 +ffff false +gggggg FALSE +iiiiii 0 diff --git a/tests/expected/libsmartcols/filter-bool-eq-true b/tests/expected/libsmartcols/filter-bool-eq-true new file mode 100644 index 0000000000..d2d9199a18 --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-eq-true @@ -0,0 +1,7 @@ +expr: BOOL == TRUE + +NAME BOOL +bbb 1 +ee true +hhh TRUE +jj 1 diff --git a/tests/expected/libsmartcols/filter-bool-eq-true2 b/tests/expected/libsmartcols/filter-bool-eq-true2 new file mode 100644 index 0000000000..12dedc2a0d --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-eq-true2 @@ -0,0 +1,7 @@ +expr: BOOL == true + +NAME BOOL +bbb 1 +ee true +hhh TRUE +jj 1 diff --git a/tests/expected/libsmartcols/filter-bool-eq-true3 b/tests/expected/libsmartcols/filter-bool-eq-true3 new file mode 100644 index 0000000000..801ee247ac --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-eq-true3 @@ -0,0 +1,7 @@ +expr: BOOL == 1 + +NAME BOOL +bbb 1 +ee true +hhh TRUE +jj 1 diff --git a/tests/expected/libsmartcols/filter-bool-is b/tests/expected/libsmartcols/filter-bool-is new file mode 100644 index 0000000000..1e8b359d67 --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-is @@ -0,0 +1,7 @@ +expr: BOOL + +NAME BOOL +bbb 1 +ee true +hhh TRUE +jj 1 diff --git a/tests/expected/libsmartcols/filter-bool-ne b/tests/expected/libsmartcols/filter-bool-ne new file mode 100644 index 0000000000..6491fad012 --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-ne @@ -0,0 +1,7 @@ +expr: BOOL != false + +NAME BOOL +bbb 1 +ee true +hhh TRUE +jj 1 diff --git a/tests/expected/libsmartcols/filter-bool-ne2 b/tests/expected/libsmartcols/filter-bool-ne2 new file mode 100644 index 0000000000..9fc684450f --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-ne2 @@ -0,0 +1,8 @@ +expr: BOOL != true + +NAME BOOL +aaaa 0 +dddddd 0 +ffff false +gggggg FALSE +iiiiii 0 diff --git a/tests/expected/libsmartcols/filter-bool-neg b/tests/expected/libsmartcols/filter-bool-neg new file mode 100644 index 0000000000..9311918c88 --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-neg @@ -0,0 +1,9 @@ +expr: !BOOL + +NAME BOOL +aaaa 0 +ccccc +dddddd 0 +ffff false +gggggg FALSE +iiiiii 0 diff --git a/tests/expected/libsmartcols/filter-bool-or b/tests/expected/libsmartcols/filter-bool-or new file mode 100644 index 0000000000..506242c71e --- /dev/null +++ b/tests/expected/libsmartcols/filter-bool-or @@ -0,0 +1,13 @@ +expr: BOOL || NAME + +NAME BOOL +aaaa 0 +bbb 1 +ccccc +dddddd 0 +ee true +ffff false +gggggg FALSE +hhh TRUE +iiiiii 0 +jj 1 diff --git a/tests/expected/libsmartcols/filter-broken-bad-column b/tests/expected/libsmartcols/filter-broken-bad-column new file mode 100644 index 0000000000..484d84ab48 --- /dev/null +++ b/tests/expected/libsmartcols/filter-broken-bad-column @@ -0,0 +1,4 @@ +expr: XXX == 100 + +sample-scols-fromfile: unknown column 'XXX' in filter +sample-scols-fromfile: failed to initialize filter diff --git a/tests/expected/libsmartcols/filter-broken-bad-float b/tests/expected/libsmartcols/filter-broken-bad-float new file mode 100644 index 0000000000..bc11bbc984 --- /dev/null +++ b/tests/expected/libsmartcols/filter-broken-bad-float @@ -0,0 +1,3 @@ +expr: NUM == 100 . 5 + +sample-scols-fromfile: failed to parse filter: diff --git a/tests/expected/libsmartcols/filter-broken-bad-number b/tests/expected/libsmartcols/filter-broken-bad-number new file mode 100644 index 0000000000..d7d5e701b2 --- /dev/null +++ b/tests/expected/libsmartcols/filter-broken-bad-number @@ -0,0 +1,3 @@ +expr: NUM == 1y0 + +sample-scols-fromfile: failed to parse filter: diff --git a/tests/expected/libsmartcols/filter-broken-bad-oper b/tests/expected/libsmartcols/filter-broken-bad-oper new file mode 100644 index 0000000000..f0600cae69 --- /dev/null +++ b/tests/expected/libsmartcols/filter-broken-bad-oper @@ -0,0 +1,3 @@ +expr: NUM ** 100 + +sample-scols-fromfile: failed to parse filter: diff --git a/tests/expected/libsmartcols/filter-broken-bad-oper2 b/tests/expected/libsmartcols/filter-broken-bad-oper2 new file mode 100644 index 0000000000..69e62a24b4 --- /dev/null +++ b/tests/expected/libsmartcols/filter-broken-bad-oper2 @@ -0,0 +1,3 @@ +expr: NUM = 100 + +sample-scols-fromfile: failed to parse filter: diff --git a/tests/expected/libsmartcols/filter-broken-no-close b/tests/expected/libsmartcols/filter-broken-no-close new file mode 100644 index 0000000000..9298977d73 --- /dev/null +++ b/tests/expected/libsmartcols/filter-broken-no-close @@ -0,0 +1,3 @@ +expr: (NUM == 100 + +sample-scols-fromfile: failed to parse filter: diff --git a/tests/expected/libsmartcols/filter-broken-no-column b/tests/expected/libsmartcols/filter-broken-no-column new file mode 100644 index 0000000000..db17bca019 --- /dev/null +++ b/tests/expected/libsmartcols/filter-broken-no-column @@ -0,0 +1,3 @@ +expr: == 100 + +sample-scols-fromfile: failed to parse filter: diff --git a/tests/expected/libsmartcols/filter-broken-no-param b/tests/expected/libsmartcols/filter-broken-no-param new file mode 100644 index 0000000000..50f18eaa05 --- /dev/null +++ b/tests/expected/libsmartcols/filter-broken-no-param @@ -0,0 +1,3 @@ +expr: NUM == + +sample-scols-fromfile: failed to parse filter: diff --git a/tests/expected/libsmartcols/filter-broken-no-start b/tests/expected/libsmartcols/filter-broken-no-start new file mode 100644 index 0000000000..227c0272d7 --- /dev/null +++ b/tests/expected/libsmartcols/filter-broken-no-start @@ -0,0 +1,3 @@ +expr: NUM == 100) + +sample-scols-fromfile: failed to parse filter: diff --git a/tests/expected/libsmartcols/filter-float-and b/tests/expected/libsmartcols/filter-float-and new file mode 100644 index 0000000000..dd733fbf4d --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-and @@ -0,0 +1,12 @@ +expr: NUM && NAME + +NAME NUM +bbb 100 +ccccc 100.5 +dddddd 99.9 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8000 +jj 8000.5 diff --git a/tests/expected/libsmartcols/filter-float-as-string b/tests/expected/libsmartcols/filter-float-as-string new file mode 100644 index 0000000000..5e2d9ebacc --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-as-string @@ -0,0 +1,4 @@ +expr: NUM == "100" + +NAME NUM +bbb 100 diff --git a/tests/expected/libsmartcols/filter-float-as-string2 b/tests/expected/libsmartcols/filter-float-as-string2 new file mode 100644 index 0000000000..a829b9c3d2 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-as-string2 @@ -0,0 +1,4 @@ +expr: NUM == "100.5" + +NAME NUM +ccccc 100.5 diff --git a/tests/expected/libsmartcols/filter-float-eq b/tests/expected/libsmartcols/filter-float-eq new file mode 100644 index 0000000000..e6e1451076 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-eq @@ -0,0 +1,4 @@ +expr: NUM == 100 + +NAME NUM +bbb 100 diff --git a/tests/expected/libsmartcols/filter-float-eq2 b/tests/expected/libsmartcols/filter-float-eq2 new file mode 100644 index 0000000000..71e27e2170 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-eq2 @@ -0,0 +1,4 @@ +expr: NUM == 100.5 + +NAME NUM +ccccc 100.5 diff --git a/tests/expected/libsmartcols/filter-float-ge b/tests/expected/libsmartcols/filter-float-ge new file mode 100644 index 0000000000..ca892d2f06 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-ge @@ -0,0 +1,11 @@ +expr: NUM >= 100 + +NAME NUM +bbb 100 +ccccc 100.5 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8000 +jj 8000.5 diff --git a/tests/expected/libsmartcols/filter-float-ge2 b/tests/expected/libsmartcols/filter-float-ge2 new file mode 100644 index 0000000000..c089fed460 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-ge2 @@ -0,0 +1,10 @@ +expr: NUM >= 100.5 + +NAME NUM +ccccc 100.5 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8000 +jj 8000.5 diff --git a/tests/expected/libsmartcols/filter-float-gt b/tests/expected/libsmartcols/filter-float-gt new file mode 100644 index 0000000000..283f13d6e5 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-gt @@ -0,0 +1,6 @@ +expr: NUM > 8000 + +NAME NUM +gggggg 678993321 +hhh 7666666 +jj 8000.5 diff --git a/tests/expected/libsmartcols/filter-float-gt2 b/tests/expected/libsmartcols/filter-float-gt2 new file mode 100644 index 0000000000..bd54c05cb2 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-gt2 @@ -0,0 +1,5 @@ +expr: NUM > 8000.5 + +NAME NUM +gggggg 678993321 +hhh 7666666 diff --git a/tests/expected/libsmartcols/filter-float-is b/tests/expected/libsmartcols/filter-float-is new file mode 100644 index 0000000000..79e30bae4e --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-is @@ -0,0 +1,12 @@ +expr: NUM + +NAME NUM +bbb 100 +ccccc 100.5 +dddddd 99.9 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8000 +jj 8000.5 diff --git a/tests/expected/libsmartcols/filter-float-le b/tests/expected/libsmartcols/filter-float-le new file mode 100644 index 0000000000..6954d68319 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-le @@ -0,0 +1,6 @@ +expr: NUM <= 100 + +NAME NUM +aaaa 0 +bbb 100 +dddddd 99.9 diff --git a/tests/expected/libsmartcols/filter-float-le2 b/tests/expected/libsmartcols/filter-float-le2 new file mode 100644 index 0000000000..c8693cc4d7 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-le2 @@ -0,0 +1,7 @@ +expr: NUM <= 100.5 + +NAME NUM +aaaa 0 +bbb 100 +ccccc 100.5 +dddddd 99.9 diff --git a/tests/expected/libsmartcols/filter-float-lt b/tests/expected/libsmartcols/filter-float-lt new file mode 100644 index 0000000000..ac67cd7d1a --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-lt @@ -0,0 +1,5 @@ +expr: NUM < 100 + +NAME NUM +aaaa 0 +dddddd 99.9 diff --git a/tests/expected/libsmartcols/filter-float-lt2 b/tests/expected/libsmartcols/filter-float-lt2 new file mode 100644 index 0000000000..0c26b03a6f --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-lt2 @@ -0,0 +1,6 @@ +expr: NUM < 100.5 + +NAME NUM +aaaa 0 +bbb 100 +dddddd 99.9 diff --git a/tests/expected/libsmartcols/filter-float-ne b/tests/expected/libsmartcols/filter-float-ne new file mode 100644 index 0000000000..b16c48e992 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-ne @@ -0,0 +1,12 @@ +expr: NUM != 100 + +NAME NUM +aaaa 0 +ccccc 100.5 +dddddd 99.9 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8000 +jj 8000.5 diff --git a/tests/expected/libsmartcols/filter-float-ne2 b/tests/expected/libsmartcols/filter-float-ne2 new file mode 100644 index 0000000000..3d5538794d --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-ne2 @@ -0,0 +1,12 @@ +expr: NUM != 100.5 + +NAME NUM +aaaa 0 +bbb 100 +dddddd 99.9 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8000 +jj 8000.5 diff --git a/tests/expected/libsmartcols/filter-float-neg b/tests/expected/libsmartcols/filter-float-neg new file mode 100644 index 0000000000..647af523d9 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-neg @@ -0,0 +1,4 @@ +expr: !NUM + +NAME NUM +aaaa 0 diff --git a/tests/expected/libsmartcols/filter-float-or b/tests/expected/libsmartcols/filter-float-or new file mode 100644 index 0000000000..40f2291b35 --- /dev/null +++ b/tests/expected/libsmartcols/filter-float-or @@ -0,0 +1,13 @@ +expr: NUM || NAME + +NAME NUM +aaaa 0 +bbb 100 +ccccc 100.5 +dddddd 99.9 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8000 +jj 8000.5 diff --git a/tests/expected/libsmartcols/filter-number-and b/tests/expected/libsmartcols/filter-number-and new file mode 100644 index 0000000000..be82bf5365 --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-and @@ -0,0 +1,12 @@ +expr: NUM && NAME + +NAME NUM +bbb 100 +ccccc 21 +dddddd 3 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8765 +jj 987456 diff --git a/tests/expected/libsmartcols/filter-number-and-or b/tests/expected/libsmartcols/filter-number-and-or new file mode 100644 index 0000000000..79ee4cb498 --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-and-or @@ -0,0 +1,7 @@ +expr: (NUM >= 3 && NUM <= 100) || NUM == 0 + +NAME NUM +aaaa 0 +bbb 100 +ccccc 21 +dddddd 3 diff --git a/tests/expected/libsmartcols/filter-number-as-string b/tests/expected/libsmartcols/filter-number-as-string new file mode 100644 index 0000000000..5e2d9ebacc --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-as-string @@ -0,0 +1,4 @@ +expr: NUM == "100" + +NAME NUM +bbb 100 diff --git a/tests/expected/libsmartcols/filter-number-eq b/tests/expected/libsmartcols/filter-number-eq new file mode 100644 index 0000000000..e6e1451076 --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-eq @@ -0,0 +1,4 @@ +expr: NUM == 100 + +NAME NUM +bbb 100 diff --git a/tests/expected/libsmartcols/filter-number-expr-and-expr b/tests/expected/libsmartcols/filter-number-expr-and-expr new file mode 100644 index 0000000000..5bc6b377c4 --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-expr-and-expr @@ -0,0 +1,7 @@ +expr: NUM > 10 && NUM < 8000 + +NAME NUM +bbb 100 +ccccc 21 +ee 411 +ffff 5111 diff --git a/tests/expected/libsmartcols/filter-number-expr-or-expr b/tests/expected/libsmartcols/filter-number-expr-or-expr new file mode 100644 index 0000000000..2e3f83bb09 --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-expr-or-expr @@ -0,0 +1,5 @@ +expr: NUM == 3 || NUM == 100 + +NAME NUM +bbb 100 +dddddd 3 diff --git a/tests/expected/libsmartcols/filter-number-ge b/tests/expected/libsmartcols/filter-number-ge new file mode 100644 index 0000000000..23899e52fd --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-ge @@ -0,0 +1,10 @@ +expr: NUM >= 100 + +NAME NUM +bbb 100 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8765 +jj 987456 diff --git a/tests/expected/libsmartcols/filter-number-gt b/tests/expected/libsmartcols/filter-number-gt new file mode 100644 index 0000000000..6668cd4a8b --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-gt @@ -0,0 +1,7 @@ +expr: NUM > 8000 + +NAME NUM +gggggg 678993321 +hhh 7666666 +iiiiii 8765 +jj 987456 diff --git a/tests/expected/libsmartcols/filter-number-is b/tests/expected/libsmartcols/filter-number-is new file mode 100644 index 0000000000..85dd3441b5 --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-is @@ -0,0 +1,12 @@ +expr: NUM + +NAME NUM +bbb 100 +ccccc 21 +dddddd 3 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8765 +jj 987456 diff --git a/tests/expected/libsmartcols/filter-number-le b/tests/expected/libsmartcols/filter-number-le new file mode 100644 index 0000000000..f2d7521e56 --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-le @@ -0,0 +1,7 @@ +expr: NUM <= 100 + +NAME NUM +aaaa 0 +bbb 100 +ccccc 21 +dddddd 3 diff --git a/tests/expected/libsmartcols/filter-number-lt b/tests/expected/libsmartcols/filter-number-lt new file mode 100644 index 0000000000..b0784db6dc --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-lt @@ -0,0 +1,6 @@ +expr: NUM < 100 + +NAME NUM +aaaa 0 +ccccc 21 +dddddd 3 diff --git a/tests/expected/libsmartcols/filter-number-ne b/tests/expected/libsmartcols/filter-number-ne new file mode 100644 index 0000000000..c2ee709480 --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-ne @@ -0,0 +1,12 @@ +expr: NUM != 100 + +NAME NUM +aaaa 0 +ccccc 21 +dddddd 3 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8765 +jj 987456 diff --git a/tests/expected/libsmartcols/filter-number-neg b/tests/expected/libsmartcols/filter-number-neg new file mode 100644 index 0000000000..647af523d9 --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-neg @@ -0,0 +1,4 @@ +expr: !NUM + +NAME NUM +aaaa 0 diff --git a/tests/expected/libsmartcols/filter-number-or b/tests/expected/libsmartcols/filter-number-or new file mode 100644 index 0000000000..8a32fac08b --- /dev/null +++ b/tests/expected/libsmartcols/filter-number-or @@ -0,0 +1,13 @@ +expr: NUM || NAME + +NAME NUM +aaaa 0 +bbb 100 +ccccc 21 +dddddd 3 +ee 411 +ffff 5111 +gggggg 678993321 +hhh 7666666 +iiiiii 8765 +jj 987456 diff --git a/tests/expected/libsmartcols/filter-string-eq b/tests/expected/libsmartcols/filter-string-eq new file mode 100644 index 0000000000..ac9688508a --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-eq @@ -0,0 +1,4 @@ +expr: NAME == "bbb" + +NAME +bbb diff --git a/tests/expected/libsmartcols/filter-string-ge b/tests/expected/libsmartcols/filter-string-ge new file mode 100644 index 0000000000..4e2d7de9d9 --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-ge @@ -0,0 +1,12 @@ +expr: NAME >= "bbb" + +NAME +bbb +ccccc +dddddd +ee +ffff +gggggg +hhh +iiiiii +jj diff --git a/tests/expected/libsmartcols/filter-string-gt b/tests/expected/libsmartcols/filter-string-gt new file mode 100644 index 0000000000..b33b8acfa1 --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-gt @@ -0,0 +1,11 @@ +expr: NAME > "bbb" + +NAME +ccccc +dddddd +ee +ffff +gggggg +hhh +iiiiii +jj diff --git a/tests/expected/libsmartcols/filter-string-is b/tests/expected/libsmartcols/filter-string-is new file mode 100644 index 0000000000..c4d8245c76 --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-is @@ -0,0 +1,13 @@ +expr: NAME + +NAME +aaaa +bbb +ccccc +dddddd +ee +ffff +gggggg +hhh +iiiiii +jj diff --git a/tests/expected/libsmartcols/filter-string-le b/tests/expected/libsmartcols/filter-string-le new file mode 100644 index 0000000000..3fea9f1c67 --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-le @@ -0,0 +1,5 @@ +expr: NAME <= "bbb" + +NAME +aaaa +bbb diff --git a/tests/expected/libsmartcols/filter-string-lt b/tests/expected/libsmartcols/filter-string-lt new file mode 100644 index 0000000000..f60cb56d59 --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-lt @@ -0,0 +1,4 @@ +expr: NAME < "bbb" + +NAME +aaaa diff --git a/tests/expected/libsmartcols/filter-string-ne b/tests/expected/libsmartcols/filter-string-ne new file mode 100644 index 0000000000..d69f05b51b --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-ne @@ -0,0 +1,12 @@ +expr: NAME != "bbb" + +NAME +aaaa +ccccc +dddddd +ee +ffff +gggggg +hhh +iiiiii +jj diff --git a/tests/expected/libsmartcols/filter-string-neg b/tests/expected/libsmartcols/filter-string-neg new file mode 100644 index 0000000000..bd5a0dd4d9 --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-neg @@ -0,0 +1,2 @@ +expr: !NAME + diff --git a/tests/expected/libsmartcols/filter-string-nreg b/tests/expected/libsmartcols/filter-string-nreg new file mode 100644 index 0000000000..e85030e066 --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-nreg @@ -0,0 +1,12 @@ +expr: NAME !~ "aaa.*" + +NAME +bbb +ccccc +dddddd +ee +ffff +gggggg +hhh +iiiiii +jj diff --git a/tests/expected/libsmartcols/filter-string-reg b/tests/expected/libsmartcols/filter-string-reg new file mode 100644 index 0000000000..3c32c0155a --- /dev/null +++ b/tests/expected/libsmartcols/filter-string-reg @@ -0,0 +1,4 @@ +expr: NAME =~ "aaa.*" + +NAME +aaaa diff --git a/tests/ts/libsmartcols/files/col-bool b/tests/ts/libsmartcols/files/col-bool new file mode 100644 index 0000000000..c3324e8a47 --- /dev/null +++ b/tests/ts/libsmartcols/files/col-bool @@ -0,0 +1 @@ +name=BOOL,right,type=boolean,json=boolean diff --git a/tests/ts/libsmartcols/files/col-float b/tests/ts/libsmartcols/files/col-float new file mode 100644 index 0000000000..7069dc714b --- /dev/null +++ b/tests/ts/libsmartcols/files/col-float @@ -0,0 +1 @@ +name=NUM,right,type=float,json=float diff --git a/tests/ts/libsmartcols/files/data-bool b/tests/ts/libsmartcols/files/data-bool new file mode 100644 index 0000000000..d6bda92860 --- /dev/null +++ b/tests/ts/libsmartcols/files/data-bool @@ -0,0 +1,10 @@ +0 +1 + +0 +true +false +FALSE +TRUE +0 +1 diff --git a/tests/ts/libsmartcols/files/data-float b/tests/ts/libsmartcols/files/data-float new file mode 100644 index 0000000000..ead3d90ff2 --- /dev/null +++ b/tests/ts/libsmartcols/files/data-float @@ -0,0 +1,10 @@ +0 +100 +100.5 +99.9 +411 +5111 +678993321 +7666666 +8000 +8000.5 diff --git a/tests/ts/libsmartcols/filter b/tests/ts/libsmartcols/filter new file mode 100755 index 0000000000..275a77a346 --- /dev/null +++ b/tests/ts/libsmartcols/filter @@ -0,0 +1,222 @@ +#!/bin/bash +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="fromfile" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBSMARTCOLS_FROMFILE" +ts_check_test_command "$TESTPROG" + +### Number +# +prefix="number" +declare -A FILTERS + +FILTERS["is"]='NUM' +FILTERS["neg"]='!NUM' +FILTERS["and"]='NUM && NAME' +FILTERS["or"]='NUM || NAME' + +FILTERS["eq"]='NUM == 100' +FILTERS["ne"]='NUM != 100' + +FILTERS["gt"]='NUM > 8000' +FILTERS["ge"]='NUM >= 100' +FILTERS["lt"]='NUM < 100' +FILTERS["le"]='NUM <= 100' + +FILTERS["expr-and-expr"]='NUM > 10 && NUM < 8000' +FILTERS["expr-or-expr"]='NUM == 3 || NUM == 100' +FILTERS["and-or"]='(NUM >= 3 && NUM <= 100) || NUM == 0' + +FILTERS["as-string"]='NUM == "100"' + +names=$(echo $(printf '%s\n' "${!FILTERS[@]}" | sort)) +for name in $names; do + ts_init_subtest "$prefix-$name" + echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT + echo >> $TS_OUTPUT + ts_run $TESTPROG --nlines 10 --width 80 \ + --filter "${FILTERS[$name]}" \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-number \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-number \ + >> $TS_OUTPUT 2> /dev/null + ts_finalize_subtest +done +FILTERS=() + + +### Float +# +prefix="float" +declare -A FILTERS + +FILTERS["is"]='NUM' +FILTERS["neg"]='!NUM' +FILTERS["and"]='NUM && NAME' +FILTERS["or"]='NUM || NAME' + +FILTERS["eq"]='NUM == 100' +FILTERS["eq2"]='NUM == 100.5' + +FILTERS["ne"]='NUM != 100' +FILTERS["ne2"]='NUM != 100.5' + +FILTERS["gt"]='NUM > 8000' +FILTERS["gt2"]='NUM > 8000.5' + +FILTERS["ge"]='NUM >= 100' +FILTERS["ge2"]='NUM >= 100.5' + +FILTERS["lt"]='NUM < 100' +FILTERS["lt2"]='NUM < 100.5' + +FILTERS["le"]='NUM <= 100' +FILTERS["le2"]='NUM <= 100.5' + +FILTERS["as-string"]='NUM == "100"' +FILTERS["as-string2"]='NUM == "100.5"' + +names=$(echo $(printf '%s\n' "${!FILTERS[@]}" | sort)) +for name in $names; do + ts_init_subtest "$prefix-$name" + echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT + echo >> $TS_OUTPUT + ts_run $TESTPROG --nlines 10 --width 80 \ + --filter "${FILTERS[$name]}" \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-float \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-float \ + >> $TS_OUTPUT 2> /dev/null + ts_finalize_subtest +done +FILTERS=() + +### Boolean +# +prefix="bool" +declare -A FILTERS + +FILTERS["is"]='BOOL' +FILTERS["neg"]='!BOOL' +FILTERS["and"]='BOOL && NAME' +FILTERS["or"]='BOOL || NAME' + +FILTERS["eq-true"]='BOOL == TRUE' +FILTERS["eq-true2"]='BOOL == true' +FILTERS["eq-true3"]='BOOL == 1' + +FILTERS["eq-false"]='BOOL == FALSE' +FILTERS["eq-false2"]='BOOL == false' +FILTERS["eq-false3"]='BOOL == 0' + +FILTERS["ne"]='BOOL != false' +FILTERS["ne2"]='BOOL != true' + +FILTERS["as-string"]='BOOL == "0"' +FILTERS["as-string2"]='BOOL == "1"' + +names=$(echo $(printf '%s\n' "${!FILTERS[@]}" | sort)) +for name in $names; do + ts_init_subtest "$prefix-$name" + echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT + echo >> $TS_OUTPUT + ts_run $TESTPROG --nlines 10 --width 80 \ + --filter "${FILTERS[$name]}" \ + --column $TS_SELF/files/col-name \ + --column $TS_SELF/files/col-bool \ + $TS_SELF/files/data-string \ + $TS_SELF/files/data-bool \ + >> $TS_OUTPUT 2> /dev/null + ts_finalize_subtest +done +FILTERS=() + + +### Strings +# +prefix="string" +declare -A FILTERS + +FILTERS["is"]='NAME' +FILTERS["neg"]='!NAME' + +FILTERS["eq"]='NAME == "bbb"' +FILTERS["ne"]='NAME != "bbb"' + +FILTERS["gt"]='NAME > "bbb"' +FILTERS["ge"]='NAME >= "bbb"' +FILTERS["lt"]='NAME < "bbb"' +FILTERS["le"]='NAME <= "bbb"' + +FILTERS["reg"]='NAME =~ "aaa.*"' +FILTERS["nreg"]='NAME !~ "aaa.*"' + +names=$(echo $(printf '%s\n' "${!FILTERS[@]}" | sort)) +for name in $names; do + ts_init_subtest "$prefix-$name" + echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT + echo >> $TS_OUTPUT + ts_run $TESTPROG --nlines 10 --width 80 \ + --filter "${FILTERS[$name]}" \ + --column $TS_SELF/files/col-name \ + $TS_SELF/files/data-string \ + >> $TS_OUTPUT 2> /dev/null + ts_finalize_subtest +done +FILTERS=() + + +### Broken +# +prefix="broken" +declare -A FILTERS + +FILTERS["no-start"]='NUM == 100)' +FILTERS["no-close"]='(NUM == 100' +FILTERS["no-column"]=' == 100' +FILTERS["no-param"]='NUM == ' +FILTERS["bad-oper"]='NUM ** 100' +FILTERS["bad-oper2"]='NUM = 100' +FILTERS["bad-column"]='XXX == 100' +FILTERS["bad-number"]='NUM == 1y0' +FILTERS["bad-float"]='NUM == 100 . 5' + +names=$(echo $(printf '%s\n' "${!FILTERS[@]}" | sort)) +for name in $names; do + ts_init_subtest "$prefix-$name" + echo "expr: ${FILTERS[$name]}" >> $TS_OUTPUT + echo >> $TS_OUTPUT + ts_run $TESTPROG --nlines 10 --width 80 \ + --filter "${FILTERS[$name]}" \ + --column $TS_SELF/files/col-number \ + $TS_SELF/files/data-number \ + 2>> $TS_OUTPUT 1> /dev/null + + sed -i -e 's/syntax error.*//g' $TS_OUTPUT + ts_finalize_subtest +done +FILTERS=() + + +ts_log "...done." +ts_finalize