blob: b58a7bb10fbdbcd4f16f996989a93f96d7fe04ca [file] [log] [blame]
Andrew Walbranbc342d42019-02-05 16:56:02 +00001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
Andrew Walbrane959ec12020-06-17 15:01:09 +01004 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/BSD-3-Clause.
Andrew Walbranbc342d42019-02-05 16:56:02 +00007 */
8
Andrew Walbranafabe852019-03-20 17:55:11 +00009#include <stddef.h>
Andrew Walbranbc342d42019-02-05 16:56:02 +000010#include <stdint.h>
11#include <stdio.h>
12#include <string.h>
13#include <unistd.h>
14
15#include "hf/memiter.h"
16
Andrew Walbranbc342d42019-02-05 16:56:02 +000017#include "hftest_common.h"
Andrew Walbran1e7c7742019-12-13 17:10:02 +000018#include "test/hftest.h"
Andrew Walbranbc342d42019-02-05 16:56:02 +000019#include <sys/reboot.h>
20
21void test_main(int argc, const char *argv[])
22{
Andrew Scull3c351e92020-01-28 11:26:05 +000023 static const char json_command[] = "json";
24 static const char run_command[] = "run";
Andrew Walbranbc342d42019-02-05 16:56:02 +000025 const char *command;
26
27 if (argc < 2) {
28 HFTEST_LOG("Unable to parse command.");
29 return;
30 }
31 command = argv[1];
32
33 hftest_use_registered_list();
34
Andrew Scull3c351e92020-01-28 11:26:05 +000035 if (strncmp(command, json_command, sizeof(json_command)) == 0) {
Andrew Walbranbc342d42019-02-05 16:56:02 +000036 hftest_json();
37 return;
38 }
39
Andrew Scull3c351e92020-01-28 11:26:05 +000040 if (strncmp(command, run_command, sizeof(run_command)) == 0) {
Andrew Walbranbc342d42019-02-05 16:56:02 +000041 struct memiter suite_name;
42 struct memiter test_name;
43
44 if (argc != 4) {
45 HFTEST_LOG("Unable to parse test.");
46 return;
47 }
48
Andrew Scull55baca62019-04-05 14:56:20 +010049 memiter_init(&suite_name, argv[2], strnlen_s(argv[2], 64));
50 memiter_init(&test_name, argv[3], strnlen_s(argv[3], 64));
Andrew Walbranafabe852019-03-20 17:55:11 +000051 hftest_run(suite_name, test_name, NULL);
Andrew Walbranbc342d42019-02-05 16:56:02 +000052 return;
53 }
54
55 hftest_help();
56}
57
58int main(int argc, const char *argv[])
59{
60 test_main(argc, argv);
61 reboot(RB_POWER_OFF);
62 return 0;
63}