Brenden Blanco | a296e1e | 2018-08-08 21:00:18 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
Andreas Gerstmayr | 7e0784d | 2017-01-16 16:35:58 +0100 | [diff] [blame] | 2 | # Copyright (c) Catalysts GmbH |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License") |
| 4 | |
Paul Chaignon | 4bb6d7f | 2017-03-30 19:05:40 +0200 | [diff] [blame] | 5 | from bcc.utils import get_online_cpus, detect_language |
Andreas Gerstmayr | 7e0784d | 2017-01-16 16:35:58 +0100 | [diff] [blame] | 6 | import multiprocessing |
| 7 | import unittest |
Paul Chaignon | 4bb6d7f | 2017-03-30 19:05:40 +0200 | [diff] [blame] | 8 | import os |
Andreas Gerstmayr | 7e0784d | 2017-01-16 16:35:58 +0100 | [diff] [blame] | 9 | |
| 10 | class 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 Chaignon | 4bb6d7f | 2017-03-30 19:05:40 +0200 | [diff] [blame] | 17 | 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 Gerstmayr | 7e0784d | 2017-01-16 16:35:58 +0100 | [diff] [blame] | 21 | |
| 22 | if __name__ == "__main__": |
| 23 | unittest.main() |