aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/core/target/base.py23
-rw-r--r--meta/lib/oeqa/core/target/qemu.py5
-rw-r--r--meta/lib/oeqa/core/target/ssh.py6
3 files changed, 33 insertions, 1 deletions
diff --git a/meta/lib/oeqa/core/target/base.py b/meta/lib/oeqa/core/target/base.py
index d2468bc257f..c8864913606 100644
--- a/meta/lib/oeqa/core/target/base.py
+++ b/meta/lib/oeqa/core/target/base.py
@@ -1,8 +1,31 @@
# Copyright (C) 2016 Intel Corporation
# Released under the MIT license (see COPYING.MIT)
+import os
+import sys
+import importlib
from abc import abstractmethod
+# Used to keep record of registered targets, it
+# uses class' targetName as the key to the class.
+targetClasses = {}
+
+def registerTarget(obj):
+ """ Use as decorator to register targets for runtime testing """
+
+ if (obj.targetName in targetClasses and
+ obj.__name__ != targetClasses[obj.targetName].__name__):
+
+ msg = ('Tried to register %s as "%s" that is used by %s' %
+ (obj, obj.targetName, targetClasses[obj.targetName]))
+ raise ImportError(msg)
+
+ if not issubclass(obj, OETarget):
+ raise TypeError('%s must inherit from OETarget' % obj)
+
+ targetClasses[obj.targetName] = obj
+ return obj
+
class OETarget(object):
def __init__(self, logger, *args, **kwargs):
diff --git a/meta/lib/oeqa/core/target/qemu.py b/meta/lib/oeqa/core/target/qemu.py
index 261c4663891..d1b6bf5dc05 100644
--- a/meta/lib/oeqa/core/target/qemu.py
+++ b/meta/lib/oeqa/core/target/qemu.py
@@ -6,12 +6,17 @@ import sys
import signal
import time
+from oeqa.core.target.base import registerTarget
from oeqa.core.target.ssh import OESSHTarget
from oeqa.utils.qemurunner import QemuRunner
supported_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic', 'elf']
+@registerTarget
class OEQemuTarget(OESSHTarget):
+
+ targetName = 'qemu'
+
def __init__(self, logger, ip, server_ip, timeout=300, user='root',
port=None, machine='', rootfs='', kernel='', kvm=False,
dump_dir='', dump_host_cmds='', display='', bootlog='',
diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py
index 035965a7a0f..d97305816fd 100644
--- a/meta/lib/oeqa/core/target/ssh.py
+++ b/meta/lib/oeqa/core/target/ssh.py
@@ -7,9 +7,13 @@ import select
import logging
import subprocess
-from oeqa.core.target.base import OETarget
+from oeqa.core.target.base import OETarget, registerTarget
+@registerTarget
class OESSHTarget(OETarget):
+
+ targetName = 'simpleremote'
+
def __init__(self, logger, ip, server_ip, timeout=300, user='root',
port=None, **kwargs):
if not logger: