build: Introduce test image with haiku_unittests package

* Currently there is no dependency between haiku_unittests.hpkg
  and unittests target. unittests needs to be built before building
  test image.

Change-Id: I7c729095db74687b154a4880fde7f15b474c3590
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2080
Reviewed-by: Kacper Kasper <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Alexander von Gluck IV
2026-01-22 17:27:44 +00:00
committed by Kacper Kasper
parent f6829b6ccf
commit cbb8d73dc9
9 changed files with 94 additions and 17 deletions
+23
View File
@@ -20,6 +20,14 @@ switch $(HAIKU_BUILD_PROFILE) {
TARGET_DEFINES += HAIKU_MINIMUM_BUILD ; TARGET_DEFINES += HAIKU_MINIMUM_BUILD ;
} }
case "test-*" : {
HAIKU_BUILD_TYPE = test ;
EnableBuildFeatures minimum_image ;
HAIKU_DEFINES += HAIKU_MINIMUM_BUILD ;
TARGET_DEFINES += HAIKU_MINIMUM_BUILD ;
}
case "*" : { case "*" : {
HAIKU_BUILD_TYPE = regular ; HAIKU_BUILD_TYPE = regular ;
EnableBuildFeatures regular_image ; EnableBuildFeatures regular_image ;
@@ -64,6 +72,9 @@ rule DefineDefaultBuildProfiles
DefineBuildProfile minimum-anyboot : anyboot-image DefineBuildProfile minimum-anyboot : anyboot-image
: "haiku-minimum-anyboot.iso" ; : "haiku-minimum-anyboot.iso" ;
# test profiles
DefineBuildProfile test-raw : image : "haiku-test.image" ;
switch $(HAIKU_BUILD_PROFILE) { switch $(HAIKU_BUILD_PROFILE) {
case "release-*" : { case "release-*" : {
Echo Building Haiku R1/development preview ; Echo Building Haiku R1/development preview ;
@@ -176,6 +187,18 @@ rule DefineDefaultBuildProfiles
; ;
} }
case "test-*" : {
Echo Building Haiku UnitTest Target ;
HAIKU_IMAGE_HOST_NAME ?= shredder ;
if $(DEBUG) != 0 {
HAIKU_IMAGE_SIZE ?= 450 ;
}
AddHaikuImageSystemPackages
openssl3
;
}
case "bootstrap-*" : { case "bootstrap-*" : {
Echo Building Haiku Bootstrap ; Echo Building Haiku Bootstrap ;
HAIKU_IMAGE_HOST_NAME ?= shredder ; HAIKU_IMAGE_HOST_NAME ?= shredder ;
+4
View File
@@ -18,6 +18,10 @@ if $(HAIKU_BUILD_TYPE) = bootstrap {
packages += Haiku ; packages += Haiku ;
} }
if $(HAIKU_BUILD_TYPE) = test {
packages += HaikuUnitTests ;
}
local archDependentPackages = local archDependentPackages =
HaikuCrossDevel HaikuCrossDevel
WebPositive WebPositive
+6
View File
@@ -7,6 +7,8 @@ if $(HAIKU_BUILD_TYPE) = bootstrap {
include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions bootstrap ] ; include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions bootstrap ] ;
} else if $(HAIKU_BUILD_TYPE) = minimum { } else if $(HAIKU_BUILD_TYPE) = minimum {
include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions minimum ] ; include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions minimum ] ;
} else if $(HAIKU_BUILD_TYPE) = test {
include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions minimum ] ;
} else { } else {
include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions regular ] ; include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions regular ] ;
} }
@@ -23,5 +25,9 @@ AddPackageFilesToHaikuImage system packages :
nameFromMetaInfo nameFromMetaInfo
; ;
if $(HAIKU_BUILD_TYPE) = test {
AddPackageFilesToHaikuImage system packages : haiku_unittests.hpkg ;
}
# import what is shared by all images # import what is shared by all images
include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions common-tail ] ; include [ FDirName $(HAIKU_BUILD_RULES_DIR) images definitions common-tail ] ;
+9
View File
@@ -0,0 +1,9 @@
local haikuUnitTestsPackage = haiku_unittests.hpkg ;
HaikuPackage $(haikuUnitTestsPackage) ;
CopyDirectoryToPackage add-ons
:
$(TARGET_UNIT_TEST_DIR)
;
BuildHaikuPackage $(haikuUnitTestsPackage) : haiku_unittests ;
+4
View File
@@ -30,6 +30,10 @@ if $(HAIKU_IS_BOOTSTRAP) != 1 && $(HAIKU_BUILD_TYPE) != minimum {
} }
} }
if $(HAIKU_BUILD_TYPE) = test {
packages += haiku_unittests ;
}
local webPositiveIsAvailable ; local webPositiveIsAvailable ;
local architectureObject ; local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] { for architectureObject in [ MultiArchSubDirSetup ] {
@@ -0,0 +1,19 @@
name haiku_unittests
version %HAIKU_VERSION%
architecture %HAIKU_PACKAGING_ARCH%
summary "Haiku unit tests"
description "Unit tests to ensure the continued stability of Haiku"
packager "The Haiku build system"
vendor "Haiku Project"
copyrights "2007-2026 Haiku, Inc."
licenses MIT
provides {
haiku_unittests=%HAIKU_VERSION%
}
requires {
haiku
}
+20 -4
View File
@@ -28,12 +28,28 @@ UnitTestLib libstoragetest.so
: be [ TargetLibstdc++ ] : be [ TargetLibstdc++ ]
; ;
rule CopyResources {
local files = $(1) ;
local sourceDir = $(2) ;
local targetDir = $(3) ;
for file in $(files) {
LOCATE on $(file) = $(sourceDir) ;
local targetFile = $(file:G=tests!unittests) ;
MakeLocate $(targetFile) : [ FDirName $(TARGET_UNIT_TEST_DIR) $(targetDir) ] ;
File $(targetFile) : $(file) ;
MODE on $(targetFile) = $(EXEMODE) ;
MimeSet $(targetFile) ;
}
}
# To run the tests some test files must be around. # To run the tests some test files must be around.
{ {
local resdir = <src!tests!kits!storage>resources ; local sourceDir = src tests kits storage resources ;
MakeLocate $(resdir) : $(TARGET_UNIT_TEST_DIR) ; local files = elf elf-no-res pef pef-no-res ppc.rsrc x86.rsrc ;
RelSymLink $(resdir) : [ FDirName $(HAIKU_TOP) src tests kits storage resources ] : false ; local sourceDirName = [ FDirName $(HAIKU_TOP) $(sourceDir) ] ;
Depends libstoragetest.so : $(resdir) ; local grist = [ FGrist $(sourceDir) ] ;
CopyResources $(files:G=$(grist)) : $(sourceDirName) : resources ;
Depends libstoragetest.so : $(files:G=tests!unittests) ;
} }
SubInclude HAIKU_TOP src tests kits storage disk_device ; SubInclude HAIKU_TOP src tests kits storage disk_device ;
+2 -8
View File
@@ -15,6 +15,8 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) cppunit ] ;
} }
} }
MakeLocate libcppunit.so : $(TARGET_UNIT_TEST_LIB_DIR) ;
SharedLibrary libcppunit.so : SharedLibrary libcppunit.so :
BTestCase.cpp BTestCase.cpp
BTestSuite.cpp BTestSuite.cpp
@@ -54,11 +56,3 @@ SharedLibrary libcppunit.so :
if ( $(OS) = BEOS || $(OS) = HAIKU ) && $(OSPLAT) != PPC { if ( $(OS) = BEOS || $(OS) = HAIKU ) && $(OSPLAT) != PPC {
LinkAgainst libcppunit.so : libelfsymbolpatcher.a debug ; LinkAgainst libcppunit.so : libelfsymbolpatcher.a debug ;
} }
# To run the tests we need the cppunit library.
{
local target = <src!tools!cppunit>libcppunit.so ;
MakeLocate $(target) : $(TARGET_UNIT_TEST_LIB_DIR) ;
RelSymLink $(target) : libcppunit.so ;
Depends libcppunit.so : $(target) ;
}
+7 -5
View File
@@ -444,26 +444,28 @@ BTestShell::LoadDynamicSuites() {
} }
set<string>::iterator i; set<string>::iterator i;
int count = 0;
for (i = fLibDirs.begin(); i != fLibDirs.end(); i++) { for (i = fLibDirs.begin(); i != fLibDirs.end(); i++) {
BDirectory libDir((*i).c_str()); BDirectory libDir((*i).c_str());
if (Verbosity() >= v3) if (Verbosity() >= v3)
cout << "Checking " << *i << endl; cout << "Checking " << *i << endl;
/* int count =*/ LoadSuitesFrom(&libDir); count += LoadSuitesFrom(&libDir);
if (Verbosity() >= v3) { if (Verbosity() >= v3) {
// cout << "Loaded " << count << " suite" << (count == 1 ? "" : "s"); cout << "Loaded " << count << " suite" << (count == 1 ? "" : "s");
// cout << " from " << *i << endl; cout << " from " << *i << endl;
} }
} }
if (Verbosity() >= v3) if (Verbosity() >= v3) {
cout << endl; cout << endl;
}
// Look for suites and tests with the same name and give a // Look for suites and tests with the same name and give a
// warning, as this is only asking for trouble... :-) // warning, as this is only asking for trouble... :-)
for (SuiteMap::const_iterator i = fSuites.begin(); i != fSuites.end(); i++) { for (SuiteMap::const_iterator i = fSuites.begin(); i != fSuites.end(); i++) {
if (fTests.find(i->first) != fTests.end() && Verbosity() > v0) { if (fTests.find(i->first) != fTests.end() && Verbosity() > v0) {
cout << "WARNING: '" << i->first << "' refers to both a test suite *and* an individual" << cout << "WARNING: '" << i->first << "' refers to both a test suite *and* an individual" <<
endl << " test. Both will be executed, but it is reccommended you rename" << endl << " test. Both will be executed, but it is recommended you rename" <<
endl << " one of them to resolve the conflict." << endl << " one of them to resolve the conflict." <<
endl << endl; endl << endl;
} }