1# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 2# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without modification, 5# are permitted provided that the following conditions are met: 6# 7# 1. Redistributions of source code must retain the above copyright notice, this list of 8# conditions and the following disclaimer. 9# 10# 2. Redistributions in binary form must reproduce the above copyright notice, this list 11# of conditions and the following disclaimer in the documentation and/or other materials 12# provided with the distribution. 13# 14# 3. Neither the name of the copyright holder nor the names of its contributors may be used 15# to endorse or promote products derived from this software without specific prior written 16# permission. 17# 18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30LITEOSTESTTOPDIR := $(shell pwd) 31LITEOSTOPDIR ?= $(LITEOSTESTTOPDIR)/.. 32export LITEOSTOPDIR 33export LITEOSTESTTOPDIR 34 35include $(LITEOSTESTTOPDIR)/config.mk 36 37RM = -rm -rf 38MAKE = make 39__LIBS = libs 40APPS = apps 41KERNEL = kernel 42TEST = test 43TEST_KERNEL = test_kernel 44TEST_APPS = test_apps 45ROOTFSDIR = rootfsdir 46ROOTFS = rootfs 47HIDE := @ 48 49LITEOS_TEST_TARGET = liteos_ktest 50LITEOS_TEST_LIBC = test_libs 51LITEOS_LIBS_TARGET = libs_target 52 53LITEOS_TEST_AUTOCONFIG_H = $(LITEOSTESTTOPDIR)/include/generated/autoconf.h 54LITEOS_TEST_KERNEL_MENUCONFIG_H = $(LITEOSTESTTOPDIR)/kernel/include 55#######LITEOS_TEST_USER_MENUCONFIG_H = $(LITEOSTESTTOPDIR)/apps/include 56ifeq ($(LOSCFG_KERNEL_TEST), y) 57LITEOS_TEST_MENUCONFIG_H = $(LITEOS_TEST_KERNEL_MENUCONFIG_H)/test_menuconfig.h 58#######else 59#######LITEOS_TEST_MENUCONFIG_H = $(LITEOS_TEST_USER_MENUCONFIG_H)/test_menuconfig.h 60endif 61 62ifeq ($(LOSCFG_STORAGE_SPINOR), y) 63FSTYPE = jffs2 64endif 65ifeq ($(LOSCFG_STORAGE_EMMC), y) 66FSTYPE = vfat 67endif 68ROOTFS_DIR = $(OUT)/rootfs 69ROOTFS_ZIP = $(OUT)/rootfs.zip 70VERSION = 71 72LITEOS_LIBDEP := $(LITEOS_BASELIB) 73 74$(TEST_KERNEL): $(LITEOS_TEST_TARGET) 75 76$(LITEOS_TEST_TARGET): $(LITEOS_TEST_LIBC) 77 $(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Map=$(OUT)/$@.map -o $(OUT)/$@ --start-group $(LITEOS_LIBDEP) --end-group 78 $(OBJCOPY) -O binary $(OUT)/$@ $(OUT)/$@.bin 79 $(OBJDUMP) -t $(OUT)/$@ |sort >$(OUT)/$@.sym.sorted 80 $(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm 81 82$(LITEOS_TEST_LIBC): $(KERNEL) 83 $(HIDE)for dir in $(TESTLIB_SUBDIRS); \ 84 do $(MAKE) -C $$dir all || exit 1; \ 85 done 86 $(HIDE)echo "=============== make lib done ===============" 87 88$(KERNEL): $(LITEOS_TEST_AUTOCONFIG_H) 89 $(HIDE)$(MAKE) -C ../ lib || exit 1 90 91##### make test menuconfig ##### 92export CONFIG_=LOSCFG_ 93MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig 94TEST_KCONFIG_FILE_PATH = $(LITEOSTESTTOPDIR)/Kconfig 95 96menuconfig:$(MENUCONFIG_PATH)/mconf 97 $< $(TEST_KCONFIG_FILE_PATH) 98 99genconfig:$(MENUCONFIG_PATH)/conf 100 $(HIDE)mkdir -p include/config include/generated 101 $< --silentoldconfig $(TEST_KCONFIG_FILE_PATH) 102 mv -f $(LITEOS_TEST_AUTOCONFIG_H) $(LITEOS_TEST_MENUCONFIG_H) 103 104##### menuconfig end ####### 105 106genconfig:$(MENUCONFIG_PATH)/conf 107 108$(LITEOS_TEST_AUTOCONFIG_H): 109ifneq ($(LITEOS_TEST_MENUCONFIG_H), $(wildcard $(LITEOS_TEST_MENUCONFIG_H))) 110 $(HIDE)$(MAKE) genconfig 111endif 112 113clean: 114 $(HIDE)$(MAKE) -C ../ clean || exit 1 115 $(HIDE)for dir in $(TESTLIB_SUBDIRS); \ 116 do $(MAKE) -C $$dir clean || exit 1; \ 117 done 118 $(HIDE)$(RM) include 119 $(HIDE)$(RM) $(LITEOS_TEST_MENUCONFIG_H) 120 $(HIDE)$(RM) $(OUT) 121.PHONY: test_apps test_kernel clean 122