File: test_utils.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 (23 lines) | stat: -rwxr-xr-x 705 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
#!/usr/bin/env python
# Copyright (c) Catalysts GmbH
# Licensed under the Apache License, Version 2.0 (the "License")

from bcc.utils import get_online_cpus, detect_language
import multiprocessing
import unittest
import os

class TestUtils(unittest.TestCase):
    def test_get_online_cpus(self):
        online_cpus = get_online_cpus()
        num_cores = multiprocessing.cpu_count()

        self.assertEqual(len(online_cpus), num_cores)

    def test_detect_language(self):
        candidates = ["c", "java", "perl", "php", "node", "ruby", "python"]
        language = detect_language(candidates, os.getpid())
        self.assertEqual(language, "python")

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