rockchip: test: add failed message for all cases

Failed message with prefix: "[UT-ERROR]: ..."

Change-Id: If44c174fc5e929d154851b4e2bf003c8a666f8b2
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-08-08 19:36:06 +08:00 committed by Kever Yang
parent 474718ff26
commit 443feaabc1
6 changed files with 52 additions and 26 deletions

View File

@ -20,6 +20,8 @@ int do_test_display(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
ret |= rockchip_show_bmp("logo_kernel.bmp");
mdelay(2000);
ut_err("display: failed to show bmp\n");
return ret;
}

View File

@ -47,6 +47,9 @@ static int do_test_tftp(cmd_tbl_t *cmdtp, int flag,
ret |= run_command("dhcp", 0);
ret |= run_command(load_cmd, 0);
if (ret)
ut_err("tftp: failed to download file\n");
return ret;
}
#endif

View File

@ -110,13 +110,13 @@ static int ir_test(void)
ret = uclass_get_device(UCLASS_RC, 0, &dev);
if (ret) {
printf("Get rc device failed: %d\n", ret);
ut_err("ir: failed to get device, ret=%d\n", ret);
goto out;
}
keycode = rc_get_keycode(dev);
if (keycode == -ENOSYS) {
printf("ir_test: failed to bind driver\n");
ut_err("ir: failed to bind driver\n");
goto out;
}
@ -132,7 +132,7 @@ static int ir_test(void)
continue;
if (keycode != last_keycode || repeat != last_repeat) {
printf("ir_test: press key:0x%x repeat:%d\n",
printf("ir: press key:0x%x repeat:%d\n",
keycode, repeat);
last_keycode = keycode;
last_repeat = repeat;
@ -200,7 +200,9 @@ static int do_test_adc(cmd_tbl_t *cmdtp, int flag,
chn = argc < 2 ? 0 : strtoul(argv[1], NULL, 10);
ret = adc_channel_single_shot("saradc", chn, &val);
if (!ret)
if (ret)
ut_err("adc: failed to get channel%d value, ret=%d\n", chn, ret);
printf("adc channel%d: adc value is %d\n", chn, val);
return ret;

View File

@ -31,12 +31,16 @@ static int regulator_change_voltage(struct udevice *dev)
/* Test get/set() */
save_uV = regulator_get_value(dev);
if (save_uV < 0)
if (save_uV < 0) {
ut_err("regulator: failed to get volt, ret=%d\n", save_uV);
return save_uV;
}
ret = regulator_set_value(dev, save_uV);
if (ret < 0)
if (ret < 0) {
ut_err("regulator: failed to set volt, ret=%d\n", ret);
return ret;
}
for (i = 1; i < 4; i++) {
uV = regulator_get_value(dev);
@ -46,7 +50,7 @@ static int regulator_change_voltage(struct udevice *dev)
regulator_get_value(dev));
if ((uV + step_uV * i) != regulator_get_value(dev)) {
printf("%s@%s: set voltage failed\n",
ut_err("regulator: %s@%s failed to set volt\n",
dev->name, uc_pdata->name);
ret = -EINVAL;
break;
@ -66,16 +70,20 @@ static int do_test_regulator(cmd_tbl_t *cmdtp, int flag,
int ret;
ret = uclass_get(UCLASS_REGULATOR, &uc);
if (ret)
if (ret) {
ut_err("regulator: failed to get uclass, ret=%d\n", ret);
return ret;
}
for (uclass_first_device(UCLASS_REGULATOR, &dev);
dev;
uclass_next_device(&dev)) {
ret = regulator_change_voltage(dev);
if (ret)
if (ret) {
ut_err("regulator: failed to change volt, ret=%d\n", ret);
return ret;
}
}
return 0;
}
@ -107,7 +115,7 @@ static int do_test_wdt(cmd_tbl_t *cmdtp, int flag,
ret = uclass_get_device(UCLASS_WDT, 0, &dev);
if (ret) {
if (ret != -ENODEV)
printf("Get watchdog device failed, ret=%d\n", ret);
ut_err("wdt: failed to get device, ret=%d\n", ret);
return ret;
}
@ -128,13 +136,13 @@ static int do_test_thermal(cmd_tbl_t *cmdtp, int flag,
ret = uclass_get_device(UCLASS_THERMAL, 0, &dev);
if (ret) {
printf("Get thermal device failed, ret=%d\n", ret);
ut_err("thermal: failed to get device, ret=%d\n", ret);
return ret;
}
ret = thermal_get_temp(dev, &temp);
if (ret) {
printf("Get temperature failed, ret=%d\n", ret);
ut_err("thermal: failed to get temperature, ret=%d\n", ret);
return ret;
}
@ -162,9 +170,11 @@ static int do_test_pmic(cmd_tbl_t *cmdtp, int flag,
env_set("this_pmic", dev->name);
run_command("pmic dev $this_pmic", 0);
ret = run_command("pmic dump", 0);
if (ret)
if (ret) {
ut_err("pmic: failed to dump register, ret=%d\n", ret);
goto out;
}
}
out:
env_set("this_pmic", NULL);

View File

@ -53,4 +53,7 @@ struct cmd_group {
#define lava_info(fmt, ...)
#endif
/* Unit test error message */
#define ut_err(fmt, args...) printf("[UT-ERROR]: "fmt, ##args)
#endif /* _TEST_ROCKCHIP_H */

View File

@ -36,14 +36,14 @@ static int do_test_storage(cmd_tbl_t *cmdtp, int flag,
/* 1. Get test partition */
dev_desc = rockchip_get_bootdev();
if (!dev_desc) {
printf("%s: Can't find dev_desc\n", __func__);
ut_err("%s: failed to get blk desc\n", label);
return -ENODEV;
}
if (part_get_info_by_name(dev_desc,
DEFAULT_STORAGE_RW_PART, &part) < 0) {
printf("%s: Can't find %s part\n",
__func__, DEFAULT_STORAGE_RW_PART);
ut_err("%s: failed to find %s partition\n", label,
DEFAULT_STORAGE_RW_PART);
return -EINVAL;
}
@ -74,14 +74,14 @@ static int do_test_storage(cmd_tbl_t *cmdtp, int flag,
/* 3. Prepare memory */
w_buf = sysmem_alloc_by_name("storage_w", blocks * dev_desc->blksz);
if (!w_buf) {
printf("No sysmem for w_buf!\n");
ut_err("%s: no sysmem for w_buf\n", label);
ret = -ENOMEM;
goto err1;
}
r_buf = sysmem_alloc_by_name("storage_r", blocks * dev_desc->blksz);
if (!r_buf) {
printf("No sysmem for r_buf!\n");
ut_err("%s: no sysmem for r_buf\n", label);
ret = -ENOMEM;
goto err2;
}
@ -98,6 +98,7 @@ static int do_test_storage(cmd_tbl_t *cmdtp, int flag,
devtype, (u32)(ulong)w_buf, sector, blocks);
for (i = 0; i < round; i++) {
if (run_command(cmd, 0)) {
ut_err("%s: failed to write @%d round\n", label, i);
ret = -EIO;
goto err3;
}
@ -106,6 +107,7 @@ static int do_test_storage(cmd_tbl_t *cmdtp, int flag,
for (i = 0; i < round; i++) {
ret = blk_dwrite(dev_desc, sector, blocks, w_buf);
if (ret != blocks) {
ut_err("%s: failed to write @%d round\n", label, i);
ret = -EIO;
goto err3;
}
@ -124,6 +126,7 @@ static int do_test_storage(cmd_tbl_t *cmdtp, int flag,
for (i = 0; i < round; i++) {
if (run_command(cmd, 0)) {
ut_err("%s: failed to read @%d round\n", label, i);
ret = -EIO;
goto err3;
}
@ -132,6 +135,7 @@ static int do_test_storage(cmd_tbl_t *cmdtp, int flag,
for (i = 0; i < round; i++) {
ret = blk_dread(dev_desc, sector, blocks, r_buf);
if (ret != blocks) {
ut_err("%s: failed to read @%d round\n", label, i);
ret = -EIO;
goto err3;
}
@ -145,7 +149,7 @@ static int do_test_storage(cmd_tbl_t *cmdtp, int flag,
/* 6. Verify the context */
for (i = 0; i < blocks * dev_desc->blksz; i++) {
if (w_buf[i] != r_buf[i]) {
printf("%s context compare error!\n", label);
ut_err("%s: context compare error\n", label);
ret = -EINVAL;
goto err3;
}
@ -156,7 +160,7 @@ static int do_test_storage(cmd_tbl_t *cmdtp, int flag,
strcmp(devnum, env_get("devnum"))) {
ret = run_command(cmd, 0);
if (ret) {
printf("Switch to mmc1 failed\n");
ut_err("%s: failed to switch to mmc1\n", label);
ret = -ENODEV;
goto err3;
}
@ -217,8 +221,10 @@ static int do_test_env(cmd_tbl_t *cmdtp, int flag,
int ret;
ret = env_save();
if (ret)
if (ret) {
ut_err("env: failed to save, ret=%d\n", ret);
return ret;
}
return env_load();
}
@ -242,13 +248,13 @@ static int do_test_efuse(cmd_tbl_t *cmdtp, int flag,
ret = uclass_get_device(UCLASS_MISC, 0, &dev);
if (ret) {
printf("Can't find efuse device\n");
ut_err("efuse: failed to get device, ret=%d\n", ret);
return 0;
}
ret = misc_read(dev, 0, &fuses, sizeof(fuses));
if (ret) {
printf("Efuse read failed\n");
ut_err("efuse: failed to read, ret=%d\n", ret);
return 0;
}
@ -270,13 +276,13 @@ static int do_test_otp(cmd_tbl_t *cmdtp, int flag,
/* retrieve the device */
ret = uclass_get_device_by_driver(UCLASS_MISC, 0, &dev);
if (ret) {
printf("Can't find otp device\n");
ut_err("otp: failed to get device, ret=%d\n", ret);
return 0;
}
ret = misc_read(dev, 0, &otps, sizeof(otps));
if (ret) {
printf("OTP read failed\n");
ut_err("otp: failed to read, ret=%d\n", ret);
return 0;
}