1#!/usr/bin/env python 2# Copyright (c) Catalysts GmbH 3# Licensed under the Apache License, Version 2.0 (the "License") 4 5from bcc.utils import get_online_cpus, detect_language 6import multiprocessing 7import unittest 8import os 9 10class TestUtils(unittest.TestCase): 11 def test_get_online_cpus(self): 12 online_cpus = get_online_cpus() 13 num_cores = multiprocessing.cpu_count() 14 15 self.assertEqual(len(online_cpus), num_cores) 16 17 def test_detect_language(self): 18 candidates = ["c", "java", "perl", "php", "node", "ruby", "python"] 19 language = detect_language(candidates, os.getpid()) 20 self.assertEqual(language, "python") 21 22if __name__ == "__main__": 23 unittest.main() 24