summaryrefslogtreecommitdiffstats
path: root/test/test_meta.sh
blob: e57a30c73f8163a636cbb3bdb00982de7334005b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#! /bin/bash

export YES_COLOR=1

export TZ=UTC
export HOME="./meta-sessions"
export XDG_CONFIG_HOME="./meta-sessions/.config"
rm -rf "./meta-sessions"
mkdir -p $HOME/.config

# add comment/tag
run_cap_test ${lnav_test} -n -dln.dbg \
    -c ":comment Hello, World!" \
    -c ":tag foo" \
    -c ":save-session" \
    -c ":write-screen-to -" \
    ${test_dir}/logfile_access_log.0

ls -lha meta-sessions
find meta-sessions
# cat ln.dbg
if test ! -d meta-sessions/.config/lnav; then
    echo "error: configuration not stored in .config/lnav?"
    exit 1
fi

if test -d meta-sessions/.lnav; then
    echo "error: configuration stored in .lnav?"
    exit 1
fi

# tag was saved and :write-to displays the comments/tags
run_cap_test ${lnav_test} -n \
    -c ":load-session" \
    -c ";UPDATE access_log SET log_mark = 1" \
    -c ":write-to -" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ":load-session" \
    -c ":untag #foo" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ":load-session" \
    -c ":clear-comment" \
    ${test_dir}/logfile_access_log.0

# search for a tag
run_cap_test ${lnav_test} -n \
    -c ":goto 2" \
    -c "/foo" \
    -c ":tag #foo" \
    -c ":goto 0" \
    -c ":next-mark search" \
    ${test_dir}/logfile_access_log.0

# query meta columns
run_cap_test ${lnav_test} -n \
    -c ":load-session" \
    -c ";SELECT log_line, log_comment, log_tags FROM access_log" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ";UPDATE access_log SET log_tags = json_array('#foo', '#foo') WHERE log_line = 1" \
    -c ":save-session" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ";UPDATE access_log SET log_comment = 'Goodbye, World!' WHERE log_line = 1" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ";UPDATE access_log SET log_tags = 1 WHERE log_line = 1" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ";UPDATE access_log SET log_tags = json_array('foo') WHERE log_line = 1" \
    -c ":save-session" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ":load-session" \
    -c ";SELECT log_tags FROM access_log WHERE log_line = 1" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ":tag foo" \
    -c ":delete-tags #foo" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ":tag foo" \
    -c ";UPDATE access_log SET log_tags = null" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ":comment foo" \
    -c ";UPDATE access_log SET log_comment = null" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -d /tmp/lnav.err -n \
    -I ${test_dir} \
    ${test_dir}/logfile_xml_msg.0

run_cap_test ${lnav_test} -n -f- \
    ${test_dir}/logfile_access_log.0 <<'EOF'
:comment Hello, **World**!

This is `markdown` now!
EOF

run_cap_test ${lnav_test} -n \
    -c ":goto 46" \
    -c ":tag bro-test" \
    -c ":save-session" \
    -c ";SELECT log_line, log_tags FROM bro_http_log WHERE log_tags IS NOT NULL" \
    ${test_dir}/logfile_bro_http.log.0

run_cap_test ${lnav_test} -n \
    -c ":load-session" \
    -c ";SELECT log_line, log_tags FROM bro_http_log WHERE log_tags IS NOT NULL" \
    ${test_dir}/logfile_bro_http.log.0

run_cap_test ${lnav_test} -n \
    -c ";UPDATE access_log SET log_annotations = '1' WHERE log_line = 0" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ";UPDATE access_log SET log_annotations = '{\"abc\": \"def\"' WHERE log_line = 0" \
    ${test_dir}/logfile_access_log.0

run_cap_test ${lnav_test} -n \
    -c ";UPDATE access_log SET log_annotations = '{\"abc\": \"def\"}' WHERE log_line = 0" \
    -c ";SELECT log_line,log_annotations FROM access_log WHERE log_annotations IS NOT NULL" \
    ${test_dir}/logfile_access_log.0