Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame^] | 1 | /* |
| 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> |
| 18 | #include <stdint.h> |
| 19 | #include <stdio.h> |
| 20 | #include <string.h> |
| 21 | #include <unistd.h> |
| 22 | |
| 23 | #include "hf/memiter.h" |
| 24 | |
| 25 | #include "hftest.h" |
| 26 | #include "hftest_common.h" |
| 27 | #include <sys/reboot.h> |
| 28 | |
| 29 | void test_main(int argc, const char *argv[]) |
| 30 | { |
| 31 | const char *command; |
| 32 | |
| 33 | if (argc < 2) { |
| 34 | HFTEST_LOG("Unable to parse command."); |
| 35 | return; |
| 36 | } |
| 37 | command = argv[1]; |
| 38 | |
| 39 | hftest_use_registered_list(); |
| 40 | |
| 41 | if (strcmp(command, "json") == 0) { |
| 42 | hftest_json(); |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | if (strcmp(command, "run") == 0) { |
| 47 | struct memiter suite_name; |
| 48 | struct memiter test_name; |
| 49 | |
| 50 | if (argc != 4) { |
| 51 | HFTEST_LOG("Unable to parse test."); |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | memiter_init(&suite_name, argv[2], strlen(argv[2])); |
| 56 | memiter_init(&test_name, argv[3], strlen(argv[3])); |
| 57 | hftest_run(suite_name, test_name); |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | hftest_help(); |
| 62 | } |
| 63 | |
| 64 | int main(int argc, const char *argv[]) |
| 65 | { |
| 66 | test_main(argc, argv); |
| 67 | reboot(RB_POWER_OFF); |
| 68 | return 0; |
| 69 | } |