blob: 6ff258ba7e71d15324ee71a09183bba5beddd0c6 [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
26#include "hftest.h"
27#include "hftest_common.h"
28#include <sys/reboot.h>
29
30void test_main(int argc, const char *argv[])
31{
32 const char *command;
33
34 if (argc < 2) {
35 HFTEST_LOG("Unable to parse command.");
36 return;
37 }
38 command = argv[1];
39
40 hftest_use_registered_list();
41
42 if (strcmp(command, "json") == 0) {
43 hftest_json();
44 return;
45 }
46
47 if (strcmp(command, "run") == 0) {
48 struct memiter suite_name;
49 struct memiter test_name;
50
51 if (argc != 4) {
52 HFTEST_LOG("Unable to parse test.");
53 return;
54 }
55
Andrew Scull55baca62019-04-05 14:56:20 +010056 memiter_init(&suite_name, argv[2], strnlen_s(argv[2], 64));
57 memiter_init(&test_name, argv[3], strnlen_s(argv[3], 64));
Andrew Walbranafabe852019-03-20 17:55:11 +000058 hftest_run(suite_name, test_name, NULL);
Andrew Walbranbc342d42019-02-05 16:56:02 +000059 return;
60 }
61
62 hftest_help();
63}
64
65int main(int argc, const char *argv[])
66{
67 test_main(argc, argv);
68 reboot(RB_POWER_OFF);
69 return 0;
70}