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