diff options
author | Rob Barnes <robbarnes@google.com> | 2021-08-20 14:36:21 +0000 |
---|---|---|
committer | Rob Barnes <robbarnes@google.com> | 2021-08-20 15:25:53 +0000 |
commit | 93adb802c1a626fbb73d762124e90be4fee08a8b (patch) | |
tree | 8ba2b19cf7a2ec4d24dde1424bfcd46d4865e231 /zephyr/zmake/tests | |
parent | 8270698e589f14239b4942a42b27132af497410b (diff) | |
download | chrome-ec-93adb802c1a626fbb73d762124e90be4fee08a8b.tar.gz |
Revert "zephyr: pull in the version string from zmake"
This reverts commit 10809eb023d475681b45863e68d906fae4667eda.
Reason for revert: Causing build errors b/197287679
Original change's description:
> zephyr: pull in the version string from zmake
>
> Zmake computes a version string and stores it in FRID/FWID, but this
> was never plumbed all the way out into the version functionality in
> the OS, which was reporting the version generated by
> util/getversion.sh.
>
> Add a mechanism to generate the version header from zmake and replace
> the getversion.sh generation with that.
>
> BUG=b:184832251
> BRANCH=none
> TEST=provided unit tests
> TEST=get this version string on posix-ec:
> posix-ec_v2.6.73347-cmsis:c3bd20,ec:c814a9,hal_stm32:f8ff8d,os:efe095
> 2021-08-18 14:10:18 jrosenth@germania
>
> Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
> Change-Id: Idec1c5f8b5f014126706e4fdc1f3d158edf40a63
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3104625
> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Bug: b:184832251
Change-Id: Ifcc4830e3097c8dc8126bb76adfeb3ce75a7a667
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3110293
Auto-Submit: Rob Barnes <robbarnes@google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Diffstat (limited to 'zephyr/zmake/tests')
-rw-r--r-- | zephyr/zmake/tests/test_util.py | 15 | ||||
-rw-r--r-- | zephyr/zmake/tests/test_version.py | 81 | ||||
-rw-r--r-- | zephyr/zmake/tests/test_zmake.py | 3 |
3 files changed, 1 insertions, 98 deletions
diff --git a/zephyr/zmake/tests/test_util.py b/zephyr/zmake/tests/test_util.py index 0524a153fd..15f92f58ab 100644 --- a/zephyr/zmake/tests/test_util.py +++ b/zephyr/zmake/tests/test_util.py @@ -87,18 +87,3 @@ def test_read_kconfig_autoconf_value(value): f.write("#define TEST {}".format(value)) read_value = util.read_kconfig_autoconf_value(path, "TEST") assert int(read_value) == value - - -@pytest.mark.parametrize( - ["input_str", "expected_result"], - [ - ("", '""'), - ("TROGDOR ABC-123", '"TROGDOR ABC-123"'), - ("hello world", '"hello world"'), - ("hello\nworld", r'"hello\nworld"'), - ('hello"world', r'"hello\"world"'), - ("hello\\world", '"hello\\\\world"'), - ], -) -def test_c_str(input_str, expected_result): - assert util.c_str(input_str) == expected_result diff --git a/zephyr/zmake/tests/test_version.py b/zephyr/zmake/tests/test_version.py index 8fb4a09435..ff8e366736 100644 --- a/zephyr/zmake/tests/test_version.py +++ b/zephyr/zmake/tests/test_version.py @@ -2,11 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import datetime import subprocess -import unittest.mock as mock - -import pytest import zmake.project import zmake.version as version @@ -100,80 +96,3 @@ def test_version_string_static(tmp_path): version.get_version_string(project, zephyr_base, modules, static=True) == "prj_v2.6.0-STATIC" ) - - -@pytest.fixture -def fake_user_hostname(): - with mock.patch("getpass.getuser", return_value="toukmond", autospec=True): - with mock.patch("platform.node", return_value="pokey", autospec=True): - yield - - -@pytest.fixture -def fake_date(): - fixed_date = datetime.datetime(2021, 6, 28, 3, 18, 53) - with mock.patch("datetime.datetime") as mock_datetime: - mock_datetime.now.return_value = fixed_date - yield - - -HEADER_VERSION_STR = "trogdor_v2.6.1004-cmsis:0dead0,hal_stm32:0beef0,os:ad00da" -EXPECTED_HEADER = ( - "/* This file is automatically generated by zmake */\n" - '#define VERSION "trogdor_v2.6.1004-cmsis:0dead0,hal_stm32:0beef0,os:ad00da"\n' - '#define CROS_EC_VERSION32 "trogdor_v2.6.1004-cmsis:0dead0,"\n' - '#define BUILDER "toukmond@pokey"\n' - '#define DATE "2021-06-28 03:18:53"\n' -) -HEADER_VERSION_STR_STATIC = "trogdor_v2.6.0-STATIC" -EXPECTED_HEADER_STATIC = ( - "/* This file is automatically generated by zmake */\n" - '#define VERSION "trogdor_v2.6.0-STATIC"\n' - '#define CROS_EC_VERSION32 "trogdor_v2.6.0-STATIC"\n' - '#define BUILDER "reproducible@build"\n' - '#define DATE "STATIC_VERSION_DATE"\n' -) - - -def test_header_gen(fake_user_hostname, fake_date, tmp_path): - # Test the simple case (static=False, no existing header). - output_file = tmp_path / "ec_version.h" - version.write_version_header(HEADER_VERSION_STR, output_file) - assert output_file.read_text() == EXPECTED_HEADER - - -def test_header_gen_reproducible_build(tmp_path): - # With static=True this time. - output_file = tmp_path / "ec_version.h" - version.write_version_header(HEADER_VERSION_STR_STATIC, output_file, static=True) - assert output_file.read_text() == EXPECTED_HEADER_STATIC - - -def test_header_gen_exists_not_changed(fake_user_hostname, fake_date, tmp_path): - # Test we don't overwrite if no changes needed. - output_file = tmp_path / "ec_version.h" - - # First time, write and record mtime. - version.write_version_header(HEADER_VERSION_STR, output_file) - expected_mtime = output_file.stat().st_mtime - - # Do another write (contents should be unchanged). - version.write_version_header(HEADER_VERSION_STR, output_file) - - # Assert we didn't write again. - assert output_file.stat().st_mtime == expected_mtime - - -def test_header_gen_exists_needs_changes(fake_user_hostname, fake_date, tmp_path): - # Test we overwrite when it exists already and changes are needed. - output_file = tmp_path / "ec_version.h" - - # First time, write and save contents. - version.write_version_header(HEADER_VERSION_STR, output_file) - original_contents = output_file.read_text() - - # Do another write (contents should be changed). - version.write_version_header(HEADER_VERSION_STR_STATIC, output_file, static=True) - - # Assert we overwrote. - assert output_file.read_text() != original_contents diff --git a/zephyr/zmake/tests/test_zmake.py b/zephyr/zmake/tests/test_zmake.py index f7978764f8..a5c132dbaa 100644 --- a/zephyr/zmake/tests/test_zmake.py +++ b/zephyr/zmake/tests/test_zmake.py @@ -141,8 +141,7 @@ EXTRAVERSION = pathlib.Path(tmpname), build_dir=pathlib.Path("build") ) else: - with patch("zmake.version.write_version_header", autospec=True): - zmk.build(pathlib.Path(tmpname)) + zmk.build(pathlib.Path(tmpname)) multiproc.wait_for_log_end() recs = [rec.getMessage() for rec in cap.records] |