diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c
index 1056a8fe9422..a4500bdd81ac 100644
--- a/src/dmidecodemodule.c
+++ b/src/dmidecodemodule.c
@@ -40,6 +40,7 @@
*. ******* AUTOHEADER END v1.1 ******* */
#include <Python.h>
+#include <sys/utsname.h>
#include <libxml/tree.h>
#include "libxml_wrap.h"
@@ -679,6 +680,9 @@ static PyObject * dmidecode_clear_warnings(PyObject *self, PyObject *null)
Py_RETURN_TRUE;
}
+static PyMethodDef DMIDataMethods_Dummy[] = {
+ {NULL, NULL, 0, NULL}
+};
static PyMethodDef DMIDataMethods[] = {
{(char *)"dump", dmidecode_dump, METH_NOARGS, (char *)"Dump dmidata to set file"},
@@ -770,6 +774,10 @@ PyMODINIT_FUNC initdmidecodemod(void)
PyObject *module = NULL;
PyObject *version = NULL;
options *opt;
+ struct utsname buf;
+
+ if (uname(&buf))
+ return;
xmlInitParser();
xmlXPathInit();
@@ -777,17 +785,22 @@ PyMODINIT_FUNC initdmidecodemod(void)
opt = (options *) malloc(sizeof(options)+2);
memset(opt, 0, sizeof(options)+2);
init(opt);
- module = Py_InitModule3((char *)"dmidecodemod", DMIDataMethods,
- "Python extension module for dmidecode");
- version = PyString_FromString(VERSION);
- Py_INCREF(version);
- PyModule_AddObject(module, "version", version);
+ if (memcmp(buf.machine, "x86_64", 6))
+ module = Py_InitModule3((char *)"dmidecodemod", DMIDataMethods_Dummy,
+ "Python extension module for dummy dmidecode");
+ else {
+ module = Py_InitModule3((char *)"dmidecodemod", DMIDataMethods,
+ "Python extension module for dmidecode");
- opt->dmiversion_n = dmidecode_get_version(opt);
- dmiver = dmixml_GetContent(opt->dmiversion_n);
- PyModule_AddObject(module, "dmi", dmiver ? PyString_FromString(dmiver) : Py_None);
+ version = PyString_FromString(VERSION);
+ Py_INCREF(version);
+ PyModule_AddObject(module, "version", version);
+ opt->dmiversion_n = dmidecode_get_version(opt);
+ dmiver = dmixml_GetContent(opt->dmiversion_n);
+ PyModule_AddObject(module, "dmi", dmiver ? PyString_FromString(dmiver) : Py_None);
+ }
// Assign this options struct to the module as well with a destructor, that way it will
// clean up the memory for us.
PyModule_AddObject(module, "options", PyCObject_FromVoidPtr(opt, destruct_options));
diff --git a/unit-tests/unit b/unit-tests/unit
index 8f9184b098c2..6e032a0c18d1 100755
--- a/unit-tests/unit
+++ b/unit-tests/unit
@@ -4,6 +4,7 @@
from pprint import pprint
import os, sys, random, tempfile, time
import commands
+import platform
from getopt import getopt
# Setup temporary sys.path() with our build dir
@@ -135,8 +136,16 @@ def vwrite(msg, vLevel=0):
sys.stdout.write(msg)
sys.stdout.flush()
+def get_machine():
+ return platform.machine()
+
################################################################################
+# no need to test on non-x86_64
+if get_machine() != "x86_64":
+ print("No need to test on non-x86_64.")
+ sys.exit(0)
+
#. Let's ignore warnings from the module for the test units...
err = open('/dev/null', 'a+', 0)
os.dup2(err.fileno(), sys.stderr.fileno())