File: per_cpu_map_cast.cpp

package info (click to toggle)
bpftrace 0.24.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,496 kB
  • sloc: cpp: 60,982; ansic: 10,952; python: 953; yacc: 665; sh: 536; lex: 295; makefile: 22
file content (73 lines) | stat: -rw-r--r-- 1,465 bytes parent folder | download
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
#include "common.h"

namespace bpftrace::test::codegen {

TEST(codegen, count_cast)
{
  test("kprobe:f { @x = count(); $res = @x; }", NAME);
}

TEST(codegen, sum_cast)
{
  test("kprobe:f { @x = sum(2); $res = @x; }", NAME);
}

TEST(codegen, min_cast)
{
  test("kprobe:f { @x = min(2); $res = @x; }", NAME);
}

TEST(codegen, max_cast)
{
  test("kprobe:f { @x = max(2); $res = @x; }", NAME);
}

TEST(codegen, avg_cast)
{
  test("kprobe:f { @x = avg(2); $res = @x; }", NAME);
}

TEST(codegen, count_cast_loop)
{
  test("kprobe:f { @x[1] = count(); for ($kv : @x) { $res = $kv.1; } }", NAME);
}

TEST(codegen, sum_cast_loop)
{
  test("kprobe:f { @x[1] = sum(2); for ($kv : @x) { $res = $kv.1; } }", NAME);
}

TEST(codegen, min_cast_loop)
{
  test("kprobe:f { @x[1] = min(2); for ($kv : @x) { $res = $kv.1; } }", NAME);
}

TEST(codegen, max_cast_loop)
{
  test("kprobe:f { @x[1] = max(2); for ($kv : @x) { $res = $kv.1; } }", NAME);
}

TEST(codegen, avg_cast_loop)
{
  test("kprobe:f { @x[1] = avg(2); for ($kv : @x) { $res = $kv.1; } }", NAME);
}

TEST(codegen, count_no_cast_for_print)
{
  test("begin { @ = count(); print(@) }", NAME);
}

TEST(codegen, count_cast_loop_multi_key)
{
  test("kprobe:f { @x[1, 2] = count(); for ($kv : @x) { $res = $kv.1; } }",
       NAME);
}

TEST(codegen, count_cast_loop_stack_key)
{
  test("kprobe:f { @x[kstack(raw)] = count(); for ($kv : @x) { $res = $kv.1; } "
       "}",
       NAME);
}

} // namespace bpftrace::test::codegen