mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
test: improve level zero black box tests
- extend test mask getter to full unsigned 32 bit integer - add getter for unsigned integer parameter - add parsing hexadecimal parameter strings Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
725323af70
commit
dc0048661a
@@ -8,6 +8,7 @@
|
||||
#include "zello_common.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
@@ -79,6 +80,28 @@ int getParamValue(int argc, char *argv[], const char *shortName, const char *lon
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
uint32_t getParamValue(int argc, char *argv[], const char *shortName, const char *longName, uint32_t defaultValue) {
|
||||
char **arg = &argv[1];
|
||||
char **argE = &argv[argc];
|
||||
char *end = nullptr;
|
||||
int base = 10;
|
||||
|
||||
for (; arg != argE; ++arg) {
|
||||
if ((0 == strcmp(*arg, shortName)) || (0 == strcmp(*arg, longName))) {
|
||||
arg++;
|
||||
if (arg == argE) {
|
||||
break;
|
||||
}
|
||||
if (strlen(*arg) > 2 && *arg[0] == '0' && *arg[1] == 'x') {
|
||||
base = 16;
|
||||
}
|
||||
return static_cast<uint32_t>(strtoul(*arg, &end, base));
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
const char *getParamValue(int argc, char *argv[], const char *shortName, const char *longName, const char *defaultString) {
|
||||
char **arg = &argv[1];
|
||||
char **argE = &argv[argc];
|
||||
@@ -673,7 +696,7 @@ ze_result_t CommandHandler::destroy() {
|
||||
}
|
||||
|
||||
TestBitMask getTestMask(int argc, char *argv[], uint32_t defaultValue) {
|
||||
uint32_t value = static_cast<uint32_t>(getParamValue(argc, argv, "-m", "-mask", static_cast<int>(defaultValue)));
|
||||
uint32_t value = getParamValue(argc, argv, "-m", "-mask", defaultValue);
|
||||
std::cout << "Test mask ";
|
||||
if (value != defaultValue) {
|
||||
std::cout << "override ";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -59,6 +59,7 @@ inline void validate(ResulT result, const char *message) {
|
||||
bool isParamEnabled(int argc, char *argv[], const char *shortName, const char *longName);
|
||||
|
||||
int getParamValue(int argc, char *argv[], const char *shortName, const char *longName, int defaultValue);
|
||||
uint32_t getParamValue(int argc, char *argv[], const char *shortName, const char *longName, uint32_t defaultValue);
|
||||
|
||||
const char *getParamValue(int argc, char *argv[], const char *shortName, const char *longName, const char *defaultString);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user