File: test_flags.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 (26 lines) | stat: -rw-r--r-- 712 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
25
26
#!/usr/bin/env python
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")

import unittest
from bcc import BPF

class TestLru(unittest.TestCase):
    def test_lru_map_flags(self):
        test_prog1 = """
        BPF_F_TABLE("lru_hash", int, u64, lru, 1024, BPF_F_NO_COMMON_LRU);
        """
        b = BPF(text=test_prog1)
        t = b["lru"]
        self.assertEqual(t.flags, 2);

    def test_hash_map_flags(self):
        test_prog1 = """
        BPF_F_TABLE("hash", int, u64, hash, 1024, BPF_F_NO_PREALLOC);
        """
        b = BPF(text=test_prog1)
        t = b["hash"]
        self.assertEqual(t.flags, 1);

if __name__ == "__main__":
    unittest.main()