blob: 0232665228cc13d907e6e871bd1b783cf0ce92f7 [file] [log] [blame]
Andrew Walbranbc342d42019-02-05 16:56:02 +00001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdalign.h>
Andrew Walbranafabe852019-03-20 17:55:11 +000018#include <stddef.h>
Andrew Walbranbc342d42019-02-05 16:56:02 +000019#include <stdint.h>
20#include <stdio.h>
21#include <string.h>
22#include <unistd.h>
23
24#include "hf/memiter.h"
25
Andrew Walbranbc342d42019-02-05 16:56:02 +000026#include "hftest_common.h"
Andrew Walbran1e7c7742019-12-13 17:10:02 +000027#include "test/hftest.h"
Andrew Walbranbc342d42019-02-05 16:56:02 +000028#include <sys/reboot.h>
29
30void test_main(int argc, const char *argv[])
31{
Andrew Scull3c351e92020-01-28 11:26:05 +000032 static const char json_command[] = "json";
33 static const char run_command[] = "run";
Andrew Walbranbc342d42019-02-05 16:56:02 +000034 const char *command;
35
36 if (argc < 2) {
37 HFTEST_LOG("Unable to parse command.");
38 return;
39 }
40 command = argv[1];
41
42 hftest_use_registered_list();
43
Andrew Scull3c351e92020-01-28 11:26:05 +000044 if (strncmp(command, json_command, sizeof(json_command)) == 0) {
Andrew Walbranbc342d42019-02-05 16:56:02 +000045 hftest_json();
46 return;
47 }
48
Andrew Scull3c351e92020-01-28 11:26:05 +000049 if (strncmp(command, run_command, sizeof(run_command)) == 0) {
Andrew Walbranbc342d42019-02-05 16:56:02 +000050 struct memiter suite_name;
51 struct memiter test_name;
52
53 if (argc != 4) {
54 HFTEST_LOG("Unable to parse test.");
55 return;
56 }
57
Andrew Scull55baca62019-04-05 14:56:20 +010058 memiter_init(&suite_name, argv[2], strnlen_s(argv[2], 64));
59 memiter_init(&test_name, argv[3], strnlen_s(argv[3], 64));
Andrew Walbranafabe852019-03-20 17:55:11 +000060 hftest_run(suite_name, test_name, NULL);
Andrew Walbranbc342d42019-02-05 16:56:02 +000061 return;
62 }
63
64 hftest_help();
65}
66
67int main(int argc, const char *argv[])
68{
69 test_main(argc, argv);
70 reboot(RB_POWER_OFF);
71 return 0;
72}