]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add libsmartcols filter tests
authorKarel Zak <kzak@redhat.com>
Mon, 20 Nov 2023 21:15:31 +0000 (22:15 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 20 Nov 2023 21:25:47 +0000 (22:25 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
71 files changed:
tests/expected/libsmartcols/filter [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-and [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-as-string [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-as-string2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-eq-false [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-eq-false2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-eq-false3 [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-eq-true [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-eq-true2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-eq-true3 [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-is [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-ne [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-ne2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-neg [new file with mode: 0644]
tests/expected/libsmartcols/filter-bool-or [new file with mode: 0644]
tests/expected/libsmartcols/filter-broken-bad-column [new file with mode: 0644]
tests/expected/libsmartcols/filter-broken-bad-float [new file with mode: 0644]
tests/expected/libsmartcols/filter-broken-bad-number [new file with mode: 0644]
tests/expected/libsmartcols/filter-broken-bad-oper [new file with mode: 0644]
tests/expected/libsmartcols/filter-broken-bad-oper2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-broken-no-close [new file with mode: 0644]
tests/expected/libsmartcols/filter-broken-no-column [new file with mode: 0644]
tests/expected/libsmartcols/filter-broken-no-param [new file with mode: 0644]
tests/expected/libsmartcols/filter-broken-no-start [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-and [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-as-string [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-as-string2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-eq [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-eq2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-ge [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-ge2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-gt [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-gt2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-is [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-le [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-le2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-lt [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-lt2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-ne [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-ne2 [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-neg [new file with mode: 0644]
tests/expected/libsmartcols/filter-float-or [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-and [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-and-or [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-as-string [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-eq [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-expr-and-expr [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-expr-or-expr [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-ge [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-gt [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-is [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-le [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-lt [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-ne [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-neg [new file with mode: 0644]
tests/expected/libsmartcols/filter-number-or [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-eq [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-ge [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-gt [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-is [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-le [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-lt [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-ne [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-neg [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-nreg [new file with mode: 0644]
tests/expected/libsmartcols/filter-string-reg [new file with mode: 0644]
tests/ts/libsmartcols/files/col-bool [new file with mode: 0644]
tests/ts/libsmartcols/files/col-float [new file with mode: 0644]
tests/ts/libsmartcols/files/data-bool [new file with mode: 0644]
tests/ts/libsmartcols/files/data-float [new file with mode: 0644]
tests/ts/libsmartcols/filter [new file with mode: 0755]

diff --git a/tests/expected/libsmartcols/filter b/tests/expected/libsmartcols/filter
new file mode 100644 (file)
index 0000000..4155aa3
--- /dev/null
@@ -0,0 +1 @@
+...done.
diff --git a/tests/expected/libsmartcols/filter-bool-and b/tests/expected/libsmartcols/filter-bool-and
new file mode 100644 (file)
index 0000000..136149c
--- /dev/null
@@ -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 (file)
index 0000000..213ce58
--- /dev/null
@@ -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 (file)
index 0000000..c4ddd20
--- /dev/null
@@ -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 (file)
index 0000000..8454205
--- /dev/null
@@ -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 (file)
index 0000000..d0d19ff
--- /dev/null
@@ -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 (file)
index 0000000..605bc93
--- /dev/null
@@ -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 (file)
index 0000000..d2d9199
--- /dev/null
@@ -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 (file)
index 0000000..12dedc2
--- /dev/null
@@ -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 (file)
index 0000000..801ee24
--- /dev/null
@@ -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 (file)
index 0000000..1e8b359
--- /dev/null
@@ -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 (file)
index 0000000..6491fad
--- /dev/null
@@ -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 (file)
index 0000000..9fc6844
--- /dev/null
@@ -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 (file)
index 0000000..9311918
--- /dev/null
@@ -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 (file)
index 0000000..506242c
--- /dev/null
@@ -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 (file)
index 0000000..484d84a
--- /dev/null
@@ -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 (file)
index 0000000..bc11bbc
--- /dev/null
@@ -0,0 +1,3 @@
+expr: NUM == 100 . 5
+
+sample-scols-fromfile: failed to parse filter: <bison syntax error message removed>
diff --git a/tests/expected/libsmartcols/filter-broken-bad-number b/tests/expected/libsmartcols/filter-broken-bad-number
new file mode 100644 (file)
index 0000000..d7d5e70
--- /dev/null
@@ -0,0 +1,3 @@
+expr: NUM == 1y0
+
+sample-scols-fromfile: failed to parse filter: <bison syntax error message removed>
diff --git a/tests/expected/libsmartcols/filter-broken-bad-oper b/tests/expected/libsmartcols/filter-broken-bad-oper
new file mode 100644 (file)
index 0000000..f0600ca
--- /dev/null
@@ -0,0 +1,3 @@
+expr: NUM ** 100
+
+sample-scols-fromfile: failed to parse filter: <bison syntax error message removed>
diff --git a/tests/expected/libsmartcols/filter-broken-bad-oper2 b/tests/expected/libsmartcols/filter-broken-bad-oper2
new file mode 100644 (file)
index 0000000..69e62a2
--- /dev/null
@@ -0,0 +1,3 @@
+expr: NUM = 100
+
+sample-scols-fromfile: failed to parse filter: <bison syntax error message removed>
diff --git a/tests/expected/libsmartcols/filter-broken-no-close b/tests/expected/libsmartcols/filter-broken-no-close
new file mode 100644 (file)
index 0000000..9298977
--- /dev/null
@@ -0,0 +1,3 @@
+expr: (NUM == 100
+
+sample-scols-fromfile: failed to parse filter: <bison syntax error message removed>
diff --git a/tests/expected/libsmartcols/filter-broken-no-column b/tests/expected/libsmartcols/filter-broken-no-column
new file mode 100644 (file)
index 0000000..db17bca
--- /dev/null
@@ -0,0 +1,3 @@
+expr:  == 100
+
+sample-scols-fromfile: failed to parse filter: <bison syntax error message removed>
diff --git a/tests/expected/libsmartcols/filter-broken-no-param b/tests/expected/libsmartcols/filter-broken-no-param
new file mode 100644 (file)
index 0000000..50f18ea
--- /dev/null
@@ -0,0 +1,3 @@
+expr: NUM == 
+
+sample-scols-fromfile: failed to parse filter: <bison syntax error message removed>
diff --git a/tests/expected/libsmartcols/filter-broken-no-start b/tests/expected/libsmartcols/filter-broken-no-start
new file mode 100644 (file)
index 0000000..227c027
--- /dev/null
@@ -0,0 +1,3 @@
+expr: NUM == 100)
+
+sample-scols-fromfile: failed to parse filter: <bison syntax error message removed>
diff --git a/tests/expected/libsmartcols/filter-float-and b/tests/expected/libsmartcols/filter-float-and
new file mode 100644 (file)
index 0000000..dd733fb
--- /dev/null
@@ -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 (file)
index 0000000..5e2d9eb
--- /dev/null
@@ -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 (file)
index 0000000..a829b9c
--- /dev/null
@@ -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 (file)
index 0000000..e6e1451
--- /dev/null
@@ -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 (file)
index 0000000..71e27e2
--- /dev/null
@@ -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 (file)
index 0000000..ca892d2
--- /dev/null
@@ -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 (file)
index 0000000..c089fed
--- /dev/null
@@ -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 (file)
index 0000000..283f13d
--- /dev/null
@@ -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 (file)
index 0000000..bd54c05
--- /dev/null
@@ -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 (file)
index 0000000..79e30ba
--- /dev/null
@@ -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 (file)
index 0000000..6954d68
--- /dev/null
@@ -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 (file)
index 0000000..c8693cc
--- /dev/null
@@ -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 (file)
index 0000000..ac67cd7
--- /dev/null
@@ -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 (file)
index 0000000..0c26b03
--- /dev/null
@@ -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 (file)
index 0000000..b16c48e
--- /dev/null
@@ -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 (file)
index 0000000..3d55387
--- /dev/null
@@ -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 (file)
index 0000000..647af52
--- /dev/null
@@ -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 (file)
index 0000000..40f2291
--- /dev/null
@@ -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 (file)
index 0000000..be82bf5
--- /dev/null
@@ -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 (file)
index 0000000..79ee4cb
--- /dev/null
@@ -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 (file)
index 0000000..5e2d9eb
--- /dev/null
@@ -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 (file)
index 0000000..e6e1451
--- /dev/null
@@ -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 (file)
index 0000000..5bc6b37
--- /dev/null
@@ -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 (file)
index 0000000..2e3f83b
--- /dev/null
@@ -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 (file)
index 0000000..23899e5
--- /dev/null
@@ -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 (file)
index 0000000..6668cd4
--- /dev/null
@@ -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 (file)
index 0000000..85dd344
--- /dev/null
@@ -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 (file)
index 0000000..f2d7521
--- /dev/null
@@ -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 (file)
index 0000000..b0784db
--- /dev/null
@@ -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 (file)
index 0000000..c2ee709
--- /dev/null
@@ -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 (file)
index 0000000..647af52
--- /dev/null
@@ -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 (file)
index 0000000..8a32fac
--- /dev/null
@@ -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 (file)
index 0000000..ac96885
--- /dev/null
@@ -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 (file)
index 0000000..4e2d7de
--- /dev/null
@@ -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 (file)
index 0000000..b33b8ac
--- /dev/null
@@ -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 (file)
index 0000000..c4d8245
--- /dev/null
@@ -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 (file)
index 0000000..3fea9f1
--- /dev/null
@@ -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 (file)
index 0000000..f60cb56
--- /dev/null
@@ -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 (file)
index 0000000..d69f05b
--- /dev/null
@@ -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 (file)
index 0000000..bd5a0dd
--- /dev/null
@@ -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 (file)
index 0000000..e85030e
--- /dev/null
@@ -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 (file)
index 0000000..3c32c01
--- /dev/null
@@ -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 (file)
index 0000000..c3324e8
--- /dev/null
@@ -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 (file)
index 0000000..7069dc7
--- /dev/null
@@ -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 (file)
index 0000000..d6bda92
--- /dev/null
@@ -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 (file)
index 0000000..ead3d90
--- /dev/null
@@ -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 (executable)
index 0000000..275a77a
--- /dev/null
@@ -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.*/<bison syntax error message removed>/g' $TS_OUTPUT
+       ts_finalize_subtest
+done
+FILTERS=()
+
+
+ts_log "...done."
+ts_finalize