blob: 54c8e73777e211e0caeda39e73d1501eeba4a224 [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
9#include <stdalign.h>
Andrew Walbranafabe852019-03-20 17:55:11 +000010#include <stddef.h>
Andrew Walbranbc342d42019-02-05 16:56:02 +000011#include <stdint.h>
12#include <stdio.h>
13#include <string.h>
14#include <unistd.h>
15
16#include "hf/memiter.h"
17
Andrew Walbranbc342d42019-02-05 16:56:02 +000018#include "hftest_common.h"
Andrew Walbran1e7c7742019-12-13 17:10:02 +000019#include "test/hftest.h"
Andrew Walbranbc342d42019-02-05 16:56:02 +000020#include <sys/reboot.h>
21
22void test_main(int argc, const char *argv[])
23{
Andrew Scull3c351e92020-01-28 11:26:05 +000024 static const char json_command[] = "json";
25 static const char run_command[] = "run";
Andrew Walbranbc342d42019-02-05 16:56:02 +000026 const char *command;
27
28 if (argc < 2) {
29 HFTEST_LOG("Unable to parse command.");
30 return;
31 }
32 command = argv[1];
33
34 hftest_use_registered_list();
35
Andrew Scull3c351e92020-01-28 11:26:05 +000036 if (strncmp(command, json_command, sizeof(json_command)) == 0) {
Andrew Walbranbc342d42019-02-05 16:56:02 +000037 hftest_json();
38 return;
39 }
40
Andrew Scull3c351e92020-01-28 11:26:05 +000041 if (strncmp(command, run_command, sizeof(run_command)) == 0) {
Andrew Walbranbc342d42019-02-05 16:56:02 +000042 struct memiter suite_name;
43 struct memiter test_name;
44
45 if (argc != 4) {
46 HFTEST_LOG("Unable to parse test.");
47 return;
48 }
49
Andrew Scull55baca62019-04-05 14:56:20 +010050 memiter_init(&suite_name, argv[2], strnlen_s(argv[2], 64));
51 memiter_init(&test_name, argv[3], strnlen_s(argv[3], 64));
Andrew Walbranafabe852019-03-20 17:55:11 +000052 hftest_run(suite_name, test_name, NULL);
Andrew Walbranbc342d42019-02-05 16:56:02 +000053 return;
54 }
55
56 hftest_help();
57}
58
59int main(int argc, const char *argv[])
60{
61 test_main(argc, argv);
62 reboot(RB_POWER_OFF);
63 return 0;
64}