|
| 1 | +# This file is part of BOINC. |
| 2 | +# https://boinc.berkeley.edu |
| 3 | +# Copyright (C) 2024 University of California |
| 4 | +# |
| 5 | +# BOINC is free software; you can redistribute it and/or modify it |
| 6 | +# under the terms of the GNU Lesser General Public License |
| 7 | +# as published by the Free Software Foundation, |
| 8 | +# either version 3 of the License, or (at your option) any later version. |
| 9 | +# |
| 10 | +# BOINC is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | +# See the GNU Lesser General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU Lesser General Public License |
| 16 | +# along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +import os |
| 19 | +import pathlib |
| 20 | +import sys |
| 21 | +import testset as testset |
| 22 | +import testhelper as testhelper |
| 23 | + |
| 24 | +class IntegrationTests: |
| 25 | + def __init__(self): |
| 26 | + self.testhelper = testhelper.TestHelper() |
| 27 | + self.result = True |
| 28 | + self.result &= self.test_version() |
| 29 | + self.result &= self.test_files_exist() |
| 30 | + |
| 31 | + def _get_test_executable_file_path(self, filename): |
| 32 | + return pathlib.Path("C:\\Program Files\\BOINC\\") / filename |
| 33 | + |
| 34 | + def _get_test_data_file_path(self, filename): |
| 35 | + return pathlib.Path("C:\\ProgramData\\BOINC\\") / filename |
| 36 | + |
| 37 | + def _get_file_version(self, filename): |
| 38 | + return self.testhelper.get_version_from_string(os.popen(("\"{app}\" --version").format(app=self._get_test_executable_file_path(filename))).read().strip()) |
| 39 | + |
| 40 | + def test_version(self): |
| 41 | + ts = testset.TestSet("Test version is correct") |
| 42 | + current_version = self.testhelper.get_current_version_number() |
| 43 | + ts.expect_not_equal("", current_version, "Test current version could be read from the 'version.h' file") |
| 44 | + ts.expect_equal(current_version, self._get_file_version("boinc.exe"), "Test 'boinc.exe' version is correctly set") |
| 45 | + ts.expect_equal(current_version, self._get_file_version("boinccmd.exe"), "Test 'boinccmd.exe' version is correctly set") |
| 46 | + return ts.result() |
| 47 | + |
| 48 | + def test_files_exist(self): |
| 49 | + ts = testset.TestSet("Test files exist") |
| 50 | + print(self._get_test_executable_file_path("boinc.exe")) |
| 51 | + ts.expect_true(os.path.exists(self._get_test_executable_file_path("boinc.exe")), "Test 'boinc.exe' file exists in 'C:\\Program Files\\BOINC\\'") |
| 52 | + ts.expect_true(os.path.exists(self._get_test_executable_file_path("boinccmd.exe")), "Test 'boinccmd.exe' file exists in 'C:\\Program Files\\BOINC\\'") |
| 53 | + ts.expect_true(os.path.exists(self._get_test_executable_file_path("boincmgr.exe")), "Test 'boincmgr.exe' file exists in 'C:\\Program Files\\BOINC\\'") |
| 54 | + ts.expect_true(os.path.exists(self._get_test_executable_file_path("boincscr.exe")), "Test 'boincscr.exe' file exists in 'C:\\Program Files\\BOINC\\'") |
| 55 | + ts.expect_true(os.path.exists(self._get_test_executable_file_path("boincsvcctrl.exe")), "Test 'boincsvcctrl.exe' file exists in 'C:\\Program Files\\BOINC\\'") |
| 56 | + ts.expect_true(os.path.exists(self._get_test_executable_file_path("boinctray.exe")), "Test 'boinctray.exe' file exists in 'C:\\Program Files\\BOINC\\'") |
| 57 | + ts.expect_true(os.path.exists(self._get_test_data_file_path("all_projects_list.xml")), "Test 'all_projects_list.xml' file exists in 'C:\\ProgramData\\BOINC\\'") |
| 58 | + return ts.result() |
| 59 | + |
| 60 | +if __name__ == "__main__": |
| 61 | + if not IntegrationTests().result: |
| 62 | + sys.exit(1) |
| 63 | + sys.exit(0) |
0 commit comments