import ctypes
import unittest

try:
    import unittest.mock as mock
except ImportError:
    import mock

import ioctl.linux


class TestLinux(unittest.TestCase):

    @mock.patch('platform.machine', return_value='i386')
    def test_i386(self, _mock):

        sizeof_ff_effect = 44
        EVIOCSFF = ioctl.linux.IOC('w', 'E', 0x80, sizeof_ff_effect)
        self.assertEqual(EVIOCSFF, 0x402c4580)

        BLKRRPART = ioctl.linux.IO(0x12, 95)
        self.assertEqual(BLKRRPART, 0x0000125f)

        RNDGETENTCNT = ioctl.linux.IOR('R', 0x00, ctypes.c_int)
        self.assertEqual(RNDGETENTCNT, 0x80045200)

        RNDADDTOENTCNT = ioctl.linux.IOW('R', 0x01, ctypes.c_int)
        self.assertEqual(RNDADDTOENTCNT, 0x40045201)

        FIFREEZE = ioctl.linux.IOWR('X', 119, ctypes.c_int)
        self.assertEqual(FIFREEZE, 0xc0045877)

@@ -123,165 +123,348 @@
 ux%0A%0A
-%0Aclass TestLinux(unittest.TestCase):%0A%0A    @mock.patch('platform.machine', return_value='i386')%0A    def test_i386(self, _mock):%0A%0A        sizeof_ff_effect = 44
+arch_values = %7B%0A    'i386': %7B%0A        'sizeof_int': 4,%0A        'sizeof_ff_effect': 44,%0A        'EVIOCSFF': 0x402c4580,%0A        'BLKRRPART': 0x0000125f,%0A        'RNDGETENTCNT': 0x80045200,%0A        'RNDADDTOENTCNT': 0x40045201,%0A        'FIFREEZE': 0xc0045877,%0A    %7D,%0A%7D%0A%0Aclass TestLinux(unittest.TestCase):%0A%0A    def _test_values(self, values):
 %0A   
@@ -511,16 +511,24 @@
 , 0x80, 
+values%5B'
 sizeof_f
@@ -535,16 +535,18 @@
 f_effect
+'%5D
 )%0A      
@@ -574,26 +574,34 @@
 IOCSFF, 
-0x402c4580
+values%5B'EVIOCSFF'%5D
 )%0A%0A     
@@ -676,26 +676,35 @@
 RRPART, 
-0x0000125f
+values%5B'BLKRRPART'%5D
 )%0A%0A     
@@ -748,28 +748,36 @@
 , 0x00, 
-ctypes.c
+values%5B'sizeof
 _int
+'%5D
 )%0A      
@@ -809,26 +809,38 @@
 ENTCNT, 
-0x80045200
+values%5B'RNDGETENTCNT'%5D
 )%0A%0A     
@@ -886,28 +886,36 @@
 , 0x01, 
-ctypes.c
+values%5B'sizeof
 _int
+'%5D
 )%0A      
@@ -949,26 +949,40 @@
 ENTCNT, 
-0x40045201
+values%5B'RNDADDTOENTCNT'%5D
 )%0A%0A     
@@ -1026,20 +1026,28 @@
 19, 
-ctypes.c
+values%5B'sizeof
 _int
+'%5D
 )%0A  
@@ -1079,20 +1079,171 @@
 FREEZE, 
-0xc0045877
+values%5B'FIFREEZE'%5D)%0A%0A    def test_i386(self):%0A        with mock.patch('platform.machine', return_value='i386'):%0A            self._test_values(arch_values%5B'i386'%5D
 )%0A

Add helper function for testing arch ioctl values.