mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-05 12:46:14 +02:00
buildman: Add a test for Boards.output_is_new()
Add a test for this code, adjusting the timestamp on various files to check each use case. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
3350d34fb5
commit
bd4ed9f72f
@ -3,9 +3,11 @@
|
||||
#
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from buildman import board
|
||||
@ -816,3 +818,62 @@ CONFIG_LOCALVERSION=y
|
||||
self.assertEquals('config2', board2['config'])
|
||||
self.assertEquals('board2', board2['target'])
|
||||
|
||||
def test_output_is_new(self):
|
||||
"""Test detecting new changes to Kconfig"""
|
||||
base = self._base_dir
|
||||
src = self._git_dir
|
||||
config_dir = os.path.join(src, 'configs')
|
||||
delay = 0.02
|
||||
|
||||
# Create a boards.cfg file
|
||||
boards_cfg = os.path.join(base, 'boards.cfg')
|
||||
content = b'''#
|
||||
# List of boards
|
||||
# Automatically generated by buildman/boards.py: don't edit
|
||||
#
|
||||
# Status, Arch, CPU, SoC, Vendor, Board, Target, Config, Maintainers
|
||||
|
||||
Active aarch64 armv8 - armltd corstone1000 board0
|
||||
Active aarch64 armv8 - armltd total_compute board2
|
||||
'''
|
||||
# Check missing file
|
||||
self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
|
||||
# Check that the board.cfg file is newer
|
||||
time.sleep(delay)
|
||||
tools.write_file(boards_cfg, content)
|
||||
self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
|
||||
# Touch the Kconfig files after a show delay to avoid a race
|
||||
time.sleep(delay)
|
||||
Path(os.path.join(src, 'Kconfig')).touch()
|
||||
self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
Path(boards_cfg).touch()
|
||||
self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
|
||||
# Touch a different Kconfig file
|
||||
time.sleep(delay)
|
||||
Path(os.path.join(src, 'Kconfig.something')).touch()
|
||||
self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
Path(boards_cfg).touch()
|
||||
self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
|
||||
# Touch a MAINTAINERS file
|
||||
time.sleep(delay)
|
||||
Path(os.path.join(src, 'MAINTAINERS')).touch()
|
||||
self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
|
||||
Path(boards_cfg).touch()
|
||||
self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
|
||||
# Touch a defconfig file
|
||||
time.sleep(delay)
|
||||
Path(os.path.join(config_dir, 'board0_defconfig')).touch()
|
||||
self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
Path(boards_cfg).touch()
|
||||
self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
|
||||
# Remove a board and check that the board.cfg file is now older
|
||||
Path(os.path.join(config_dir, 'board0_defconfig')).unlink()
|
||||
self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user