mirror of
https://review.coreboot.org/chrome-ec.git
synced 2024-09-09 06:12:42 +02:00
genvif: add unit test for genvif and genvif override
Any of the following will run the test from platform/ec make buildall make runtests make run-genvif_test The following will run the test from platform/ec/test/genvif make clean test BUG=b:173219559 BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ic5594ae96d040adc332c2afc8fa8a8eb8b373882 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2542745 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
This commit is contained in:
parent
72f06af17e
commit
73b90bcbad
15 changed files with 310 additions and 1 deletions
|
@ -359,7 +359,7 @@ hosttests: $(host-test-targets)
|
|||
runhosttests: TEST_FLAG=TEST_HOSTTEST=y
|
||||
runhosttests: $(run-test-targets)
|
||||
runfuzztests: $(run-fuzz-test-targets)
|
||||
runtests: runhosttests runfuzztests
|
||||
runtests: runhosttests runfuzztests run-genvif_test
|
||||
|
||||
# Automatically enumerate all suites.
|
||||
cts_excludes := common
|
||||
|
|
|
@ -228,3 +228,7 @@ is_enabled_error-y=is_enabled_error.o.cmd
|
|||
|
||||
host-static_if_error: TEST_SCRIPT=static_if_error.sh
|
||||
static_if_error-y=static_if_error.o.cmd
|
||||
|
||||
run-genvif_test:
|
||||
@echo " TEST genvif_test"
|
||||
@test/genvif/genvif.sh
|
||||
|
|
2
test/genvif/.gitignore
vendored
Normal file
2
test/genvif/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
genvif
|
||||
vif_output
|
24
test/genvif/Makefile
Normal file
24
test/genvif/Makefile
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
#
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-O2 -Isrc -I../../include
|
||||
|
||||
genvif: ../../util/genvif.c src/helper.c
|
||||
@$(CC) -o $@ $^ $(CFLAGS)
|
||||
|
||||
test: genvif
|
||||
@mkdir vif_output 2>/dev/null
|
||||
@./genvif -b test -o vif_output
|
||||
@./genvif -b exp_test -o vif_output -n -v vif/exp_test_vif.xml
|
||||
@diff vif_output/test_vif.xml vif_output/exp_test_vif.xml
|
||||
@./genvif -b test_over -o vif_output -v vif/over_test_vif.xml
|
||||
@./genvif -b exp_test_over -o vif_output -n -v vif/exp_test_over_vif.xml
|
||||
@diff vif_output/test_over_vif.xml vif_output/exp_test_over_vif.xml
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -f genvif
|
||||
@rm -rf vif_output
|
8
test/genvif/genvif.sh
Executable file
8
test/genvif/genvif.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash -e
|
||||
# Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
cd test/genvif
|
||||
make clean
|
||||
make test
|
8
test/genvif/src/atomic.h
Normal file
8
test/genvif/src/atomic.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Blank shell to avoid including the real file
|
||||
*/
|
9
test/genvif/src/board.h
Normal file
9
test/genvif/src/board.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#define PD_OPERATING_POWER_MW 15000
|
||||
#define PD_MAX_POWER_MW 65000
|
||||
#define PD_MAX_CURRENT_MA 3250
|
||||
#define PD_MAX_VOLTAGE_MV 20000
|
8
test/genvif/src/config_chip.h
Normal file
8
test/genvif/src/config_chip.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Blank shell to avoid including the real file
|
||||
*/
|
8
test/genvif/src/fuzz_config.h
Normal file
8
test/genvif/src/fuzz_config.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Blank shell to avoid including the real file
|
||||
*/
|
29
test/genvif/src/helper.c
Normal file
29
test/genvif/src/helper.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "usb_pd.h"
|
||||
|
||||
#ifndef CONFIG_USB_PD_CUSTOM_PDO
|
||||
#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP |\
|
||||
PDO_FIXED_COMM_CAP)
|
||||
|
||||
const uint32_t pd_src_pdo[] = {
|
||||
PDO_FIXED(5000, 1500, PDO_FIXED_FLAGS),
|
||||
};
|
||||
const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo);
|
||||
const uint32_t pd_src_pdo_max[] = {
|
||||
PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS),
|
||||
};
|
||||
const int pd_src_pdo_max_cnt = ARRAY_SIZE(pd_src_pdo_max);
|
||||
|
||||
const uint32_t pd_snk_pdo[] = {
|
||||
PDO_FIXED(5000, 500, PDO_FIXED_FLAGS),
|
||||
PDO_BATT(4750, PD_MAX_VOLTAGE_MV, PD_OPERATING_POWER_MW),
|
||||
PDO_VAR(4750, PD_MAX_VOLTAGE_MV, PD_MAX_CURRENT_MA),
|
||||
};
|
||||
const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo);
|
||||
#endif /* CONFIG_USB_PD_CUSTOM_PDO */
|
||||
|
8
test/genvif/src/test_config.h
Normal file
8
test/genvif/src/test_config.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Blank shell to avoid including the real file
|
||||
*/
|
8
test/genvif/src/timer.h
Normal file
8
test/genvif/src/timer.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Blank shell to avoid including the real file
|
||||
*/
|
88
test/genvif/vif/exp_test_over_vif.xml
Normal file
88
test/genvif/vif/exp_test_over_vif.xml
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<VIF>
|
||||
<VIF_Specification>3.12</VIF_Specification>
|
||||
<Vendor_Name>Google</Vendor_Name>
|
||||
<Model_Part_Number>SuperTestWithOverride</Model_Part_Number>
|
||||
<Product_Revision>Final</Product_Revision>
|
||||
<TID>12345</TID>
|
||||
<VIF_Product_Type value="0">Port Product</VIF_Product_Type>
|
||||
<Certification_Type value="0">End Product</Certification_Type>
|
||||
<Product>
|
||||
<Product_VID value="6353">18D1</Product_VID>
|
||||
</Product>
|
||||
<Component>
|
||||
<Port_Label>0</Port_Label>
|
||||
<Connector_Type value="2">Type-C®</Connector_Type>
|
||||
<USB4_Supported value="false">NO</USB4_Supported>
|
||||
<USB_PD_Support value="true">YES</USB_PD_Support>
|
||||
<PD_Port_Type value="4">DRP</PD_Port_Type>
|
||||
<Type_C_State_Machine value="2">DRP</Type_C_State_Machine>
|
||||
<Captive_Cable value="false">NO</Captive_Cable>
|
||||
<Port_Battery_Powered value="false">NO</Port_Battery_Powered>
|
||||
<BC_1_2_Support value="0">None</BC_1_2_Support>
|
||||
<PD_Spec_Revision_Major value="3" />
|
||||
<PD_Spec_Revision_Minor value="0" />
|
||||
<PD_Spec_Version_Major value="2" />
|
||||
<PD_Spec_Version_Minor value="0" />
|
||||
<PD_Specification_Revision value="2">Revision 3</PD_Specification_Revision>
|
||||
<USB_Comms_Capable value="true">YES</USB_Comms_Capable>
|
||||
<DR_Swap_To_DFP_Supported value="true">YES</DR_Swap_To_DFP_Supported>
|
||||
<DR_Swap_To_UFP_Supported value="false">NO</DR_Swap_To_UFP_Supported>
|
||||
<Unconstrained_Power value="false">NO</Unconstrained_Power>
|
||||
<VCONN_Swap_To_On_Supported value="false">NO</VCONN_Swap_To_On_Supported>
|
||||
<VCONN_Swap_To_Off_Supported value="false">NO</VCONN_Swap_To_Off_Supported>
|
||||
<Responds_To_Discov_SOP_UFP value="false">NO</Responds_To_Discov_SOP_UFP>
|
||||
<Responds_To_Discov_SOP_DFP value="false">NO</Responds_To_Discov_SOP_DFP>
|
||||
<Attempts_Discov_SOP value="true">YES</Attempts_Discov_SOP>
|
||||
<Chunking_Implemented_SOP value="false">NO</Chunking_Implemented_SOP>
|
||||
<Unchunked_Extended_Messages_Supported value="false">NO</Unchunked_Extended_Messages_Supported>
|
||||
<Manufacturer_Info_Supported_Port value="false">NO</Manufacturer_Info_Supported_Port>
|
||||
<Security_Msgs_Supported_SOP value="false">NO</Security_Msgs_Supported_SOP>
|
||||
<Num_Fixed_Batteries value="1" />
|
||||
<Num_Swappable_Battery_Slots value="0" />
|
||||
<ID_Header_Connector_Type_SOP value="2">USB Type-C® Receptacle</ID_Header_Connector_Type_SOP>
|
||||
<SOP_Capable value="true">YES</SOP_Capable>
|
||||
<SOP_P_Capable value="false">NO</SOP_P_Capable>
|
||||
<SOP_PP_Capable value="false">NO</SOP_PP_Capable>
|
||||
<SOP_P_Debug_Capable value="false">NO</SOP_P_Debug_Capable>
|
||||
<SOP_PP_Debug_Capable value="false">NO</SOP_PP_Debug_Capable>
|
||||
<Type_C_Implements_Try_SRC value="false">NO</Type_C_Implements_Try_SRC>
|
||||
<Type_C_Implements_Try_SNK value="false">NO</Type_C_Implements_Try_SNK>
|
||||
<RP_Value value="1">1.5A</RP_Value>
|
||||
<Type_C_Is_VCONN_Powered_Accessory value="false">NO</Type_C_Is_VCONN_Powered_Accessory>
|
||||
<Type_C_Is_Debug_Target_SRC value="true">YES</Type_C_Is_Debug_Target_SRC>
|
||||
<Type_C_Is_Debug_Target_SNK value="true">YES</Type_C_Is_Debug_Target_SNK>
|
||||
<Type_C_Can_Act_As_Host value="true">YES</Type_C_Can_Act_As_Host>
|
||||
<Type_C_Is_Alt_Mode_Controller value="false">NO</Type_C_Is_Alt_Mode_Controller>
|
||||
<Type_C_Can_Act_As_Device value="false">NO</Type_C_Can_Act_As_Device>
|
||||
<Type_C_Is_Alt_Mode_Adapter value="false">NO</Type_C_Is_Alt_Mode_Adapter>
|
||||
<Type_C_Power_Source value="1">UFP-powered</Type_C_Power_Source>
|
||||
<Type_C_Port_On_Hub value="false">NO</Type_C_Port_On_Hub>
|
||||
<Type_C_Supports_Audio_Accessory value="false">NO</Type_C_Supports_Audio_Accessory>
|
||||
<Type_C_Sources_VCONN value="false">NO</Type_C_Sources_VCONN>
|
||||
<Device_Speed value="0">USB 2</Device_Speed>
|
||||
<Host_Speed value="0">USB 2</Host_Speed>
|
||||
<Host_Contains_Captive_Retimer value="false">NO</Host_Contains_Captive_Retimer>
|
||||
<Host_Is_Embedded value="false">NO</Host_Is_Embedded>
|
||||
<PD_Power_As_Source value="15000">15000 mW</PD_Power_As_Source>
|
||||
<USB_Suspend_May_Be_Cleared value="false">NO</USB_Suspend_May_Be_Cleared>
|
||||
<FR_Swap_Type_C_Current_Capability_As_Initial_Sink value="0">FR_Swap not supported</FR_Swap_Type_C_Current_Capability_As_Initial_Sink>
|
||||
<Master_Port value="false">NO</Master_Port>
|
||||
<Num_Src_PDOs value="1" />
|
||||
<PD_OC_Protection value="false">NO</PD_OC_Protection>
|
||||
<XID_SOP value="0" />
|
||||
<PID_SOP value="65535">FFFF</PID_SOP>
|
||||
<Product_Total_Source_Power_mW value="15000">15000 mW</Product_Total_Source_Power_mW>
|
||||
<Port_Source_Power_Type value="0">Assured</Port_Source_Power_Type>
|
||||
<SrcPdoList>
|
||||
<SrcPDO>
|
||||
<Src_PDO_Supply_Type value="0">Fixed</Src_PDO_Supply_Type>
|
||||
<Src_PDO_Peak_Current value="0">100% IOC</Src_PDO_Peak_Current>
|
||||
<Src_PDO_Voltage value="100">5000 mV</Src_PDO_Voltage>
|
||||
<Src_PDO_Max_Current value="300">3000 mA</Src_PDO_Max_Current>
|
||||
<Src_PD_OCP_OC_Debounce value="50">50 msec</Src_PD_OCP_OC_Debounce>
|
||||
<Src_PD_OCP_OC_Threshold value="360">3600 mA</Src_PD_OCP_OC_Threshold>
|
||||
</SrcPDO>
|
||||
</SrcPdoList>
|
||||
</Component>
|
||||
</VIF>
|
86
test/genvif/vif/exp_test_vif.xml
Normal file
86
test/genvif/vif/exp_test_vif.xml
Normal file
|
@ -0,0 +1,86 @@
|
|||
<VIF>
|
||||
<VIF_Specification>3.12</VIF_Specification>
|
||||
<Vendor_Name>Google</Vendor_Name>
|
||||
<Model_Part_Number>test</Model_Part_Number>
|
||||
<Product_Revision>FIX-ME</Product_Revision>
|
||||
<TID>65535</TID>
|
||||
<VIF_Product_Type value="0">Port Product</VIF_Product_Type>
|
||||
<Certification_Type value="0">End Product</Certification_Type>
|
||||
<Product>
|
||||
<Product_VID value="6353">18D1</Product_VID>
|
||||
</Product>
|
||||
<Component>
|
||||
<Port_Label>0</Port_Label>
|
||||
<Connector_Type value="2">Type-C®</Connector_Type>
|
||||
<USB4_Supported value="false">NO</USB4_Supported>
|
||||
<USB_PD_Support value="true">YES</USB_PD_Support>
|
||||
<PD_Port_Type value="4">DRP</PD_Port_Type>
|
||||
<Type_C_State_Machine value="2">DRP</Type_C_State_Machine>
|
||||
<Captive_Cable value="false">NO</Captive_Cable>
|
||||
<Port_Battery_Powered value="false">NO</Port_Battery_Powered>
|
||||
<BC_1_2_Support value="0">None</BC_1_2_Support>
|
||||
<PD_Spec_Revision_Major value="3" />
|
||||
<PD_Spec_Revision_Minor value="0" />
|
||||
<PD_Spec_Version_Major value="2" />
|
||||
<PD_Spec_Version_Minor value="0" />
|
||||
<PD_Specification_Revision value="2">Revision 3</PD_Specification_Revision>
|
||||
<USB_Comms_Capable value="true">YES</USB_Comms_Capable>
|
||||
<DR_Swap_To_DFP_Supported value="true">YES</DR_Swap_To_DFP_Supported>
|
||||
<DR_Swap_To_UFP_Supported value="false">NO</DR_Swap_To_UFP_Supported>
|
||||
<Unconstrained_Power value="false">NO</Unconstrained_Power>
|
||||
<VCONN_Swap_To_On_Supported value="false">NO</VCONN_Swap_To_On_Supported>
|
||||
<VCONN_Swap_To_Off_Supported value="false">NO</VCONN_Swap_To_Off_Supported>
|
||||
<Responds_To_Discov_SOP_UFP value="false">NO</Responds_To_Discov_SOP_UFP>
|
||||
<Responds_To_Discov_SOP_DFP value="false">NO</Responds_To_Discov_SOP_DFP>
|
||||
<Attempts_Discov_SOP value="true">YES</Attempts_Discov_SOP>
|
||||
<Chunking_Implemented_SOP value="false">NO</Chunking_Implemented_SOP>
|
||||
<Unchunked_Extended_Messages_Supported value="false">NO</Unchunked_Extended_Messages_Supported>
|
||||
<Manufacturer_Info_Supported_Port value="false">NO</Manufacturer_Info_Supported_Port>
|
||||
<Security_Msgs_Supported_SOP value="false">NO</Security_Msgs_Supported_SOP>
|
||||
<Num_Fixed_Batteries value="1" />
|
||||
<Num_Swappable_Battery_Slots value="0" />
|
||||
<ID_Header_Connector_Type_SOP value="2">USB Type-C® Receptacle</ID_Header_Connector_Type_SOP>
|
||||
<SOP_Capable value="true">YES</SOP_Capable>
|
||||
<SOP_P_Capable value="false">NO</SOP_P_Capable>
|
||||
<SOP_PP_Capable value="false">NO</SOP_PP_Capable>
|
||||
<SOP_P_Debug_Capable value="false">NO</SOP_P_Debug_Capable>
|
||||
<SOP_PP_Debug_Capable value="false">NO</SOP_PP_Debug_Capable>
|
||||
<Type_C_Implements_Try_SRC value="false">NO</Type_C_Implements_Try_SRC>
|
||||
<Type_C_Implements_Try_SNK value="false">NO</Type_C_Implements_Try_SNK>
|
||||
<RP_Value value="1">1.5A</RP_Value>
|
||||
<Type_C_Is_VCONN_Powered_Accessory value="false">NO</Type_C_Is_VCONN_Powered_Accessory>
|
||||
<Type_C_Is_Debug_Target_SRC value="true">YES</Type_C_Is_Debug_Target_SRC>
|
||||
<Type_C_Is_Debug_Target_SNK value="true">YES</Type_C_Is_Debug_Target_SNK>
|
||||
<Type_C_Can_Act_As_Host value="true">YES</Type_C_Can_Act_As_Host>
|
||||
<Type_C_Is_Alt_Mode_Controller value="false">NO</Type_C_Is_Alt_Mode_Controller>
|
||||
<Type_C_Can_Act_As_Device value="false">NO</Type_C_Can_Act_As_Device>
|
||||
<Type_C_Is_Alt_Mode_Adapter value="false">NO</Type_C_Is_Alt_Mode_Adapter>
|
||||
<Type_C_Power_Source value="1">UFP-powered</Type_C_Power_Source>
|
||||
<Type_C_Port_On_Hub value="false">NO</Type_C_Port_On_Hub>
|
||||
<Type_C_Supports_Audio_Accessory value="false">NO</Type_C_Supports_Audio_Accessory>
|
||||
<Type_C_Sources_VCONN value="false">NO</Type_C_Sources_VCONN>
|
||||
<Device_Speed value="0">USB 2</Device_Speed>
|
||||
<Host_Speed value="0">USB 2</Host_Speed>
|
||||
<Host_Contains_Captive_Retimer value="false">NO</Host_Contains_Captive_Retimer>
|
||||
<Host_Is_Embedded value="false">NO</Host_Is_Embedded>
|
||||
<PD_Power_As_Source value="15000">15000 mW</PD_Power_As_Source>
|
||||
<USB_Suspend_May_Be_Cleared value="false">NO</USB_Suspend_May_Be_Cleared>
|
||||
<Sends_Pings value="false">NO</Sends_Pings>
|
||||
<FR_Swap_Type_C_Current_Capability_As_Initial_Sink value="0">FR_Swap not supported</FR_Swap_Type_C_Current_Capability_As_Initial_Sink>
|
||||
<Master_Port value="false">NO</Master_Port>
|
||||
<Num_Src_PDOs value="1" />
|
||||
<PD_OC_Protection value="false">NO</PD_OC_Protection>
|
||||
<XID_SOP value="0" />
|
||||
<PID_SOP value="65535">FFFF</PID_SOP>
|
||||
<Product_Total_Source_Power_mW value="15000">15000 mW</Product_Total_Source_Power_mW>
|
||||
<Port_Source_Power_Type value="0">Assured</Port_Source_Power_Type>
|
||||
<SrcPdoList>
|
||||
<SrcPDO>
|
||||
<Src_PDO_Supply_Type value="0">Fixed</Src_PDO_Supply_Type>
|
||||
<Src_PDO_Peak_Current value="0">100% IOC</Src_PDO_Peak_Current>
|
||||
<Src_PDO_Voltage value="100">5000 mV</Src_PDO_Voltage>
|
||||
<Src_PDO_Max_Current value="300">3000 mA</Src_PDO_Max_Current>
|
||||
</SrcPDO>
|
||||
</SrcPdoList>
|
||||
</Component>
|
||||
</VIF>
|
19
test/genvif/vif/over_test_vif.xml
Normal file
19
test/genvif/vif/over_test_vif.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<VIF>
|
||||
<!-- Override the following fields -->
|
||||
<Model_Part_Number>SuperTestWithOverride</Model_Part_Number>
|
||||
<Product_Revision>Final</Product_Revision>
|
||||
<TID>12345</TID>
|
||||
|
||||
<Component>
|
||||
<!-- Remove Sends_Pings -->
|
||||
<Sends_Pings />
|
||||
|
||||
<SrcPdoList>
|
||||
<SrcPDO>
|
||||
<!-- Add in missing fields for SrcPdo0 -->
|
||||
<Src_PD_OCP_OC_Debounce value="50">50 msec</Src_PD_OCP_OC_Debounce>
|
||||
<Src_PD_OCP_OC_Threshold value="360">3600 mA</Src_PD_OCP_OC_Threshold>
|
||||
</SrcPDO>
|
||||
</SrcPdoList>
|
||||
</Component>
|
||||
</VIF>
|
Loading…
Reference in a new issue