xref: /aosp_15_r20/external/bcc/tests/python/test_flags.py (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1#!/usr/bin/env python3
2# Copyright (c) PLUMgrid, Inc.
3# Licensed under the Apache License, Version 2.0 (the "License")
4
5import unittest
6from bcc import BPF
7
8class TestLru(unittest.TestCase):
9    def test_lru_map_flags(self):
10        test_prog1 = b"""
11        BPF_F_TABLE("lru_hash", int, u64, lru, 1024, BPF_F_NO_COMMON_LRU);
12        """
13        b = BPF(text=test_prog1)
14        t = b[b"lru"]
15        self.assertEqual(t.flags, 2);
16
17    def test_hash_map_flags(self):
18        test_prog1 = b"""
19        BPF_F_TABLE("hash", int, u64, hash, 1024, BPF_F_NO_PREALLOC);
20        """
21        b = BPF(text=test_prog1)
22        t = b[b"hash"]
23        self.assertEqual(t.flags, 1);
24
25if __name__ == "__main__":
26    unittest.main()
27