Merge "Convert omx hal test to use VtsHalHidlTargetTestEnvBase"

am: 03086cfea4

Change-Id: I91df7ffcb229125a939c6f59ed3f9b050c786aaf
This commit is contained in:
Zhuoyao Zhang 2018-02-12 23:14:51 +00:00 committed by android-build-merger
commit 162e15e590
7 changed files with 82 additions and 433 deletions

View file

@ -50,85 +50,6 @@ using ::android::sp;
#include <media_hidl_test_common.h>
#include <fstream>
// A class for test environment setup
class ComponentTestEnvironment : public ::testing::Environment {
public:
virtual void SetUp() {}
virtual void TearDown() {}
ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {}
void setInstance(const char* _instance) { instance = _instance; }
void setComponent(const char* _component) { component = _component; }
void setRole(const char* _role) { role = _role; }
void setRes(const char* _res) { res = _res; }
const hidl_string getInstance() const { return instance; }
const hidl_string getComponent() const { return component; }
const hidl_string getRole() const { return role; }
const hidl_string getRes() const { return res; }
int initFromOptions(int argc, char** argv) {
static struct option options[] = {
{"instance", required_argument, 0, 'I'},
{"component", required_argument, 0, 'C'},
{"role", required_argument, 0, 'R'},
{"res", required_argument, 0, 'P'},
{0, 0, 0, 0}};
while (true) {
int index = 0;
int c = getopt_long(argc, argv, "I:C:R:P:", options, &index);
if (c == -1) {
break;
}
switch (c) {
case 'I':
setInstance(optarg);
break;
case 'C':
setComponent(optarg);
break;
case 'R':
setRole(optarg);
break;
case 'P':
setRes(optarg);
break;
case '?':
break;
}
}
if (optind < argc) {
fprintf(stderr,
"unrecognized option: %s\n\n"
"usage: %s <gtest options> <test options>\n\n"
"test options are:\n\n"
"-I, --instance: HAL instance to test\n"
"-C, --component: OMX component to test\n"
"-R, --role: OMX component Role\n"
"-P, --res: Resource files directory location\n",
argv[optind ?: 1], argv[0]);
return 2;
}
return 0;
}
private:
hidl_string instance;
hidl_string component;
hidl_string role;
hidl_string res;
};
static ComponentTestEnvironment* gEnv = nullptr;
// audio decoder test fixture class
@ -1220,6 +1141,7 @@ int main(int argc, char** argv) {
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();

View file

@ -50,85 +50,6 @@ using ::android::sp;
#include <media_hidl_test_common.h>
#include <fstream>
// A class for test environment setup
class ComponentTestEnvironment : public ::testing::Environment {
public:
virtual void SetUp() {}
virtual void TearDown() {}
ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {}
void setInstance(const char* _instance) { instance = _instance; }
void setComponent(const char* _component) { component = _component; }
void setRole(const char* _role) { role = _role; }
void setRes(const char* _res) { res = _res; }
const hidl_string getInstance() const { return instance; }
const hidl_string getComponent() const { return component; }
const hidl_string getRole() const { return role; }
const hidl_string getRes() const { return res; }
int initFromOptions(int argc, char** argv) {
static struct option options[] = {
{"instance", required_argument, 0, 'I'},
{"component", required_argument, 0, 'C'},
{"role", required_argument, 0, 'R'},
{"res", required_argument, 0, 'P'},
{0, 0, 0, 0}};
while (true) {
int index = 0;
int c = getopt_long(argc, argv, "I:C:R:P:", options, &index);
if (c == -1) {
break;
}
switch (c) {
case 'I':
setInstance(optarg);
break;
case 'C':
setComponent(optarg);
break;
case 'R':
setRole(optarg);
break;
case 'P':
setRes(optarg);
break;
case '?':
break;
}
}
if (optind < argc) {
fprintf(stderr,
"unrecognized option: %s\n\n"
"usage: %s <gtest options> <test options>\n\n"
"test options are:\n\n"
"-I, --instance: HAL instance to test\n"
"-C, --component: OMX component to test\n"
"-R, --role: OMX component Role\n"
"-P, --res: Resource files directory location\n",
argv[optind ?: 1], argv[0]);
return 2;
}
return 0;
}
private:
hidl_string instance;
hidl_string component;
hidl_string role;
hidl_string res;
};
static ComponentTestEnvironment* gEnv = nullptr;
// audio encoder test fixture class
@ -562,6 +483,7 @@ int main(int argc, char** argv) {
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();

View file

@ -21,6 +21,7 @@
#define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
#endif
#include <getopt.h>
#include <media/stagefright/foundation/ALooper.h>
#include <utils/Condition.h>
#include <utils/List.h>
@ -33,6 +34,8 @@
#include <media/openmax/OMX_AudioExt.h>
#include <media/openmax/OMX_VideoExt.h>
#include <VtsHalHidlTargetTestEnvBase.h>
/* TIME OUTS (Wait time in dequeueMessage()) */
/* As component is switching states (loaded<->idle<->execute), dequeueMessage()
@ -355,4 +358,77 @@ void testEOS(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
portreconfig fptr = nullptr, OMX_U32 kPortIndexInput = 0,
OMX_U32 kPortIndexOutput = 1, void* args = nullptr);
// A class for test environment setup
class ComponentTestEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
private:
typedef ::testing::VtsHalHidlTargetTestEnvBase Super;
public:
virtual void registerTestServices() override { registerTestService<IOmx>(); }
ComponentTestEnvironment() : res("/sdcard/media/") {}
void setComponent(const char* _component) { component = _component; }
void setRole(const char* _role) { role = _role; }
void setRes(const char* _res) { res = _res; }
const hidl_string getInstance() { return Super::getServiceName<IOmx>(); }
const hidl_string getComponent() const { return component; }
const hidl_string getRole() const { return role; }
const hidl_string getRes() const { return res; }
int initFromOptions(int argc, char** argv) {
static struct option options[] = {{"component", required_argument, 0, 'C'},
{"role", required_argument, 0, 'R'},
{"res", required_argument, 0, 'P'},
{0, 0, 0, 0}};
while (true) {
int index = 0;
int c = getopt_long(argc, argv, "C:R:P:", options, &index);
if (c == -1) {
break;
}
switch (c) {
case 'C':
setComponent(optarg);
break;
case 'R':
setRole(optarg);
break;
case 'P':
setRes(optarg);
break;
case '?':
break;
}
}
if (optind < argc) {
fprintf(stderr,
"unrecognized option: %s\n\n"
"usage: %s <gtest options> <test options>\n\n"
"test options are:\n\n"
"-C, --component: OMX component to test\n"
"-R, --role: OMX component Role\n"
"-P, --res: Resource files directory location\n",
argv[optind ?: 1], argv[0]);
return 2;
}
return 0;
}
private:
hidl_string instance;
hidl_string component;
hidl_string role;
hidl_string res;
};
#endif // MEDIA_HIDL_TEST_COMMON_H

View file

@ -48,75 +48,6 @@ using ::android::sp;
#include <getopt.h>
#include <media_hidl_test_common.h>
// A class for test environment setup
class ComponentTestEnvironment : public ::testing::Environment {
public:
virtual void SetUp() {}
virtual void TearDown() {}
ComponentTestEnvironment() : instance("default") {}
void setInstance(const char* _instance) { instance = _instance; }
void setComponent(const char* _component) { component = _component; }
void setRole(const char* _role) { role = _role; }
const hidl_string getInstance() const { return instance; }
const hidl_string getComponent() const { return component; }
const hidl_string getRole() const { return role; }
int initFromOptions(int argc, char** argv) {
static struct option options[] = {
{"instance", required_argument, 0, 'I'},
{"component", required_argument, 0, 'C'},
{"role", required_argument, 0, 'R'},
{0, 0, 0, 0}};
while (true) {
int index = 0;
int c = getopt_long(argc, argv, "I:C:R:", options, &index);
if (c == -1) {
break;
}
switch (c) {
case 'I':
setInstance(optarg);
break;
case 'C':
setComponent(optarg);
break;
case 'R':
setRole(optarg);
break;
case '?':
break;
}
}
if (optind < argc) {
fprintf(stderr,
"unrecognized option: %s\n\n"
"usage: %s <gtest options> <test options>\n\n"
"test options are:\n\n"
"-I, --instance: HAL instance to test\n"
"-C, --component: OMX component to test\n"
"-R, --Role: OMX component Role\n",
argv[optind ?: 1], argv[0]);
return 2;
}
return 0;
}
private:
hidl_string instance;
hidl_string component;
hidl_string role;
};
static ComponentTestEnvironment* gEnv = nullptr;
// generic component test fixture class
@ -1321,6 +1252,7 @@ int main(int argc, char** argv) {
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();

View file

@ -50,54 +50,6 @@ using ::android::sp;
#include <getopt.h>
#include <media_hidl_test_common.h>
// A class for test environment setup
class ComponentTestEnvironment : public ::testing::Environment {
public:
virtual void SetUp() {}
virtual void TearDown() {}
ComponentTestEnvironment() : instance("default") {}
void setInstance(const char* _instance) { instance = _instance; }
const hidl_string getInstance() const { return instance; }
int initFromOptions(int argc, char** argv) {
static struct option options[] = {
{"instance", required_argument, 0, 'I'}, {0, 0, 0, 0}};
while (true) {
int index = 0;
int c = getopt_long(argc, argv, "I:", options, &index);
if (c == -1) {
break;
}
switch (c) {
case 'I':
setInstance(optarg);
break;
case '?':
break;
}
}
if (optind < argc) {
fprintf(stderr,
"unrecognized option: %s\n\n"
"usage: %s <gtest options> <test options>\n\n"
"test options are:\n\n"
"-I, --instance: HAL instance to test\n",
argv[optind ?: 1], argv[0]);
return 2;
}
return 0;
}
private:
hidl_string instance;
};
static ComponentTestEnvironment* gEnv = nullptr;
class MasterHidlTest : public ::testing::VtsHalHidlTargetTestBase {
@ -226,6 +178,7 @@ int main(int argc, char** argv) {
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();

View file

@ -51,85 +51,6 @@ using ::android::sp;
#include <media_video_hidl_test_common.h>
#include <fstream>
// A class for test environment setup
class ComponentTestEnvironment : public ::testing::Environment {
public:
virtual void SetUp() {}
virtual void TearDown() {}
ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {}
void setInstance(const char* _instance) { instance = _instance; }
void setComponent(const char* _component) { component = _component; }
void setRole(const char* _role) { role = _role; }
void setRes(const char* _res) { res = _res; }
const hidl_string getInstance() const { return instance; }
const hidl_string getComponent() const { return component; }
const hidl_string getRole() const { return role; }
const hidl_string getRes() const { return res; }
int initFromOptions(int argc, char** argv) {
static struct option options[] = {
{"instance", required_argument, 0, 'I'},
{"component", required_argument, 0, 'C'},
{"role", required_argument, 0, 'R'},
{"res", required_argument, 0, 'P'},
{0, 0, 0, 0}};
while (true) {
int index = 0;
int c = getopt_long(argc, argv, "I:C:R:P:", options, &index);
if (c == -1) {
break;
}
switch (c) {
case 'I':
setInstance(optarg);
break;
case 'C':
setComponent(optarg);
break;
case 'R':
setRole(optarg);
break;
case 'P':
setRes(optarg);
break;
case '?':
break;
}
}
if (optind < argc) {
fprintf(stderr,
"unrecognized option: %s\n\n"
"usage: %s <gtest options> <test options>\n\n"
"test options are:\n\n"
"-I, --instance: HAL instance to test\n"
"-C, --component: OMX component to test\n"
"-R, --role: OMX component Role\n"
"-P, --res: Resource files directory location\n",
argv[optind ?: 1], argv[0]);
return 2;
}
return 0;
}
private:
hidl_string instance;
hidl_string component;
hidl_string role;
hidl_string res;
};
static ComponentTestEnvironment* gEnv = nullptr;
// video decoder test fixture class
@ -1488,6 +1409,7 @@ int main(int argc, char** argv) {
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();

View file

@ -64,85 +64,6 @@ using ::android::sp;
#include <system/window.h>
#include <fstream>
// A class for test environment setup
class ComponentTestEnvironment : public ::testing::Environment {
public:
virtual void SetUp() {}
virtual void TearDown() {}
ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {}
void setInstance(const char* _instance) { instance = _instance; }
void setComponent(const char* _component) { component = _component; }
void setRole(const char* _role) { role = _role; }
void setRes(const char* _res) { res = _res; }
const hidl_string getInstance() const { return instance; }
const hidl_string getComponent() const { return component; }
const hidl_string getRole() const { return role; }
const hidl_string getRes() const { return res; }
int initFromOptions(int argc, char** argv) {
static struct option options[] = {
{"instance", required_argument, 0, 'I'},
{"component", required_argument, 0, 'C'},
{"role", required_argument, 0, 'R'},
{"res", required_argument, 0, 'P'},
{0, 0, 0, 0}};
while (true) {
int index = 0;
int c = getopt_long(argc, argv, "I:C:R:P:", options, &index);
if (c == -1) {
break;
}
switch (c) {
case 'I':
setInstance(optarg);
break;
case 'C':
setComponent(optarg);
break;
case 'R':
setRole(optarg);
break;
case 'P':
setRes(optarg);
break;
case '?':
break;
}
}
if (optind < argc) {
fprintf(stderr,
"unrecognized option: %s\n\n"
"usage: %s <gtest options> <test options>\n\n"
"test options are:\n\n"
"-I, --instance: HAL instance to test\n"
"-C, --component: OMX component to test\n"
"-R, --role: OMX component Role\n"
"-P, --res: Resource files directory location\n",
argv[optind ?: 1], argv[0]);
return 2;
}
return 0;
}
private:
hidl_string instance;
hidl_string component;
hidl_string role;
hidl_string res;
};
static ComponentTestEnvironment* gEnv = nullptr;
// video encoder test fixture class
@ -1580,6 +1501,7 @@ int main(int argc, char** argv) {
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();