File: test_dump_func.py

package info (click to toggle)
bpfcc 0.18.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,368 kB
  • sloc: ansic: 132,727; python: 36,226; cpp: 26,973; sh: 710; yacc: 525; makefile: 141; lex: 94
file content (24 lines) | stat: -rwxr-xr-x 586 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")

# test program for the 'dump_func' method

from bcc import BPF
from unittest import main, TestCase

class TestDumpFunc(TestCase):
    def test_return(self):
        b = BPF(text="""
            int entry(void)
            {
                return 1;
            }""")

        self.assertEqual(
            b"\xb7\x00\x00\x00\x01\x00\x00\x00" +
            b"\x95\x00\x00\x00\x00\x00\x00\x00",
            b.dump_func("entry"))

if __name__ == "__main__":
    main()