Blame SOURCES/disable_loading_dmidecodemodule_on_non_x86_64.patch

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