Skip to content

Commit 99d50e1

Browse files
Jordan Romejordalgo
authored andcommitted
Fix: json formatting for strftime
This should be output as a string when json formatting is selected.
1 parent 90e4289 commit 99d50e1

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ and this project adheres to
4949
- #[3339](https://github.com/bpftrace/bpftrace/pull/3339)
5050
- Fix parsing large unsigned int strings as positional params
5151
- [#3336](https://github.com/bpftrace/bpftrace/pull/3336)
52+
- Fix json formatting for `strftime` function
53+
- [#3381](https://github.com/bpftrace/bpftrace/pull/3381)
5254
#### Security
5355
#### Docs
5456
- Remove mention of unsupported character literals

src/output.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ bool is_quoted_type(const SizedType &ty)
2727
case Type::probe:
2828
case Type::strerror:
2929
case Type::string:
30+
case Type::timestamp:
3031
case Type::username:
3132
case Type::ustack:
3233
case Type::usym:
@@ -46,7 +47,6 @@ bool is_quoted_type(const SizedType &ty)
4647
case Type::stack_mode:
4748
case Type::stats:
4849
case Type::sum:
49-
case Type::timestamp:
5050
case Type::timestamp_mode:
5151
case Type::tuple:
5252
case Type::voidtype:

tests/runtime/json-output

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,8 @@ NAME cgroup_path
183183
RUN {{BPFTRACE}} -q -f json -e 'BEGIN { print(cgroup_path(cgroup)); exit(); }' | python3 -c 'import sys,json; print(json.load(sys.stdin))'
184184
EXPECT_REGEX ^{'type': 'value', 'data': '.*'}$
185185
TIMEOUT 5
186+
187+
NAME strftime
188+
RUN {{BPFTRACE}} -q -f json -e 'BEGIN { $t = (1, strftime("%m/%d/%y", nsecs)); print($t); exit() }' | python3 -c 'import sys,json; print(json.load(sys.stdin))'
189+
EXPECT_REGEX ^{'type': 'value', 'data': \[1, '[0-9]{2}\/[0-9]{2}\/[0-9]{2}'\]}$
190+
TIMEOUT 1

0 commit comments

Comments
 (0)