tests: subsys: mgmt: move ec_host_cmd to new ztest API

Move test ec_host_cmd to use new ztest API.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
diff --git a/tests/subsys/mgmt/ec_host_cmd/prj.conf b/tests/subsys/mgmt/ec_host_cmd/prj.conf
index 9cf38f5..ce34a81 100644
--- a/tests/subsys/mgmt/ec_host_cmd/prj.conf
+++ b/tests/subsys/mgmt/ec_host_cmd/prj.conf
@@ -2,3 +2,4 @@
 CONFIG_EC_HOST_CMD_PERIPH=y
 CONFIG_EC_HOST_CMD_SIMULATOR=y
 CONFIG_ZTEST=y
+CONFIG_ZTEST_NEW_API=y
diff --git a/tests/subsys/mgmt/ec_host_cmd/src/main.c b/tests/subsys/mgmt/ec_host_cmd/src/main.c
index a0982ac..b0c6865 100644
--- a/tests/subsys/mgmt/ec_host_cmd/src/main.c
+++ b/tests/subsys/mgmt/ec_host_cmd/src/main.c
@@ -166,7 +166,7 @@
 EC_HOST_CMD_HANDLER(ec_host_cmd_add, EC_CMD_HELLO, BIT(0) | BIT(1) | BIT(2),
 		    struct ec_params_add, struct ec_response_add);
 
-static void test_add(void)
+ZTEST(ec_host_cmd, test_add)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = EC_CMD_HELLO;
@@ -187,7 +187,7 @@
 	verify_tx_data();
 }
 
-static void test_add_version_2(void)
+ZTEST(ec_host_cmd, test_add_version_2)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = EC_CMD_HELLO;
@@ -208,7 +208,7 @@
 	verify_tx_data();
 }
 
-static void test_add_invalid_version(void)
+ZTEST(ec_host_cmd, test_add_invalid_version)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = EC_CMD_HELLO;
@@ -222,7 +222,7 @@
 	verify_tx_error(EC_HOST_CMD_INVALID_VERSION);
 }
 
-static void test_add_invalid_version_big(void)
+ZTEST(ec_host_cmd, test_add_invalid_version_big)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = EC_CMD_HELLO;
@@ -236,7 +236,7 @@
 	verify_tx_error(EC_HOST_CMD_INVALID_VERSION);
 }
 
-static void test_add_invalid_prtcl_ver_2(void)
+ZTEST(ec_host_cmd, test_add_invalid_prtcl_ver_2)
 {
 	host_to_dut->header.prtcl_ver = 2;
 	host_to_dut->header.cmd_id = EC_CMD_HELLO;
@@ -250,7 +250,7 @@
 	verify_tx_error(EC_HOST_CMD_INVALID_HEADER);
 }
 
-static void test_add_invalid_prtcl_ver_4(void)
+ZTEST(ec_host_cmd, test_add_invalid_prtcl_ver_4)
 {
 	host_to_dut->header.prtcl_ver = 4;
 	host_to_dut->header.cmd_id = EC_CMD_HELLO;
@@ -264,7 +264,7 @@
 	verify_tx_error(EC_HOST_CMD_INVALID_HEADER);
 }
 
-static void test_add_invalid_rx_checksum(void)
+ZTEST(ec_host_cmd, test_add_invalid_rx_checksum)
 {
 	int rv;
 
@@ -292,7 +292,7 @@
 	verify_tx_error(EC_HOST_CMD_INVALID_CHECKSUM);
 }
 
-static void test_add_rx_size_too_small_for_header(void)
+ZTEST(ec_host_cmd, test_add_rx_size_too_small_for_header)
 {
 	int rv;
 
@@ -313,7 +313,7 @@
 	verify_tx_error(EC_HOST_CMD_REQUEST_TRUNCATED);
 }
 
-static void test_add_rx_size_too_small(void)
+ZTEST(ec_host_cmd, test_add_rx_size_too_small)
 {
 	int rv;
 
@@ -336,7 +336,7 @@
 	verify_tx_error(EC_HOST_CMD_REQUEST_TRUNCATED);
 }
 
-static void test_unknown_command(void)
+ZTEST(ec_host_cmd, test_unknown_command)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = 1234;
@@ -388,7 +388,7 @@
 EC_HOST_CMD_HANDLER_UNBOUND(ec_host_cmd_unbounded, EC_CMD_UNBOUNDED,
 			    BIT(0) | BIT(1) | BIT(2));
 
-static void test_unbounded_handler_error_return(void)
+ZTEST(ec_host_cmd, test_unbounded_handler_error_return)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = EC_CMD_UNBOUNDED;
@@ -402,7 +402,7 @@
 	verify_tx_error(EC_HOST_CMD_OVERFLOW);
 }
 
-static void test_unbounded_handler_response_too_big(void)
+ZTEST(ec_host_cmd, test_unbounded_handler_response_too_big)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = EC_CMD_UNBOUNDED;
@@ -416,7 +416,7 @@
 	verify_tx_error(EC_HOST_CMD_INVALID_RESPONSE);
 }
 
-static void test_rx_buffer_cleared_foreach_hostcommand(void)
+ZTEST(ec_host_cmd, test_rx_buffer_cleared_foreach_hostcommand)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = EC_CMD_UNBOUNDED;
@@ -445,7 +445,7 @@
 	verify_tx_data();
 }
 
-static void test_tx_buffer_cleared_foreach_hostcommand(void)
+ZTEST(ec_host_cmd, test_tx_buffer_cleared_foreach_hostcommand)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = EC_CMD_UNBOUNDED;
@@ -488,7 +488,7 @@
 EC_HOST_CMD_HANDLER(ec_host_cmd_too_big, EC_CMD_TOO_BIG, BIT(0), uint32_t,
 		    struct ec_response_too_big);
 
-static void test_response_always_too_big(void)
+ZTEST(ec_host_cmd, test_response_always_too_big)
 {
 	host_to_dut->header.prtcl_ver = 3;
 	host_to_dut->header.cmd_id = EC_CMD_TOO_BIG;
@@ -501,26 +501,10 @@
 	verify_tx_error(EC_HOST_CMD_INVALID_RESPONSE);
 }
 
-void test_main(void)
+static void *ec_host_cmd_tests_setup(void)
 {
 	ec_host_cmd_periph_sim_install_send_cb(host_send);
-
-	ztest_test_suite(
-		ec_host_cmd_tests, ztest_unit_test(test_add),
-		ztest_unit_test(test_add_version_2),
-		ztest_unit_test(test_add_invalid_prtcl_ver_2),
-		ztest_unit_test(test_add_invalid_prtcl_ver_4),
-		ztest_unit_test(test_add_invalid_version),
-		ztest_unit_test(test_add_invalid_version_big),
-		ztest_unit_test(test_add_invalid_rx_checksum),
-		ztest_unit_test(test_add_rx_size_too_small_for_header),
-		ztest_unit_test(test_add_rx_size_too_small),
-		ztest_unit_test(test_unknown_command),
-		ztest_unit_test(test_unbounded_handler_error_return),
-		ztest_unit_test(test_unbounded_handler_response_too_big),
-		ztest_unit_test(test_rx_buffer_cleared_foreach_hostcommand),
-		ztest_unit_test(test_tx_buffer_cleared_foreach_hostcommand),
-		ztest_unit_test(test_response_always_too_big));
-
-	ztest_run_test_suite(ec_host_cmd_tests);
+	return NULL;
 }
+
+ZTEST_SUITE(ec_host_cmd, NULL, ec_host_cmd_tests_setup, NULL, NULL, NULL);