blob: 2959482a5ab3f46774a9e1bac3417795648263fa [file] [log] [blame]
Andreas Gerstmayr7e0784d2017-01-16 16:35:58 +01001#!/usr/bin/python
2# Copyright (c) Catalysts GmbH
3# Licensed under the Apache License, Version 2.0 (the "License")
4
Paul Chaignon4bb6d7f2017-03-30 19:05:40 +02005from bcc.utils import get_online_cpus, detect_language
Andreas Gerstmayr7e0784d2017-01-16 16:35:58 +01006import multiprocessing
7import unittest
Paul Chaignon4bb6d7f2017-03-30 19:05:40 +02008import os
Andreas Gerstmayr7e0784d2017-01-16 16:35:58 +01009
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
Paul Chaignon4bb6d7f2017-03-30 19:05:40 +020017 def test_detect_language(self):
18 candidates = ["java", "ruby", "php", "node", "c", "python"]
19 language = detect_language(candidates, os.getpid())
20 self.assertEqual(language, "python")
Andreas Gerstmayr7e0784d2017-01-16 16:35:58 +010021
22if __name__ == "__main__":
23 unittest.main()