Пример #1
0
 def test_function_typedef(self):
     source = """
     struct work_struct;
     typedef void (*work_func_t)(struct work_struct *work);
     void delayed_work_timer_fn(unsigned long __data);
     """
     actual = trimming_parser.build_snippets(source)
     self.assertTrue("work_func_t" in actual)
Пример #2
0
 def test_function_typedef(self):
     source = """
     struct work_struct;
     typedef void (*work_func_t)(struct work_struct *work);
     void delayed_work_timer_fn(unsigned long __data);
     """
     actual = trimming_parser.build_snippets(source)
     self.assertTrue("work_func_t" in actual)
Пример #3
0
    def test_anonymous_enum(self):
        source = """
        struct work_struct work;
}; enum {
        WQ_UNBOUND              = 1 << 1,
        WQ_FREEZABLE            = 1 << 2,
        WQ_MEM_RECLAIM          = 1 << 3,
        WQ_HIGHPRI              = 1 << 4,
        WQ_CPU_INTENSIVE        = 1 << 5,
        WQ_SYSFS                = 1 << 6,


        WQ_POWER_EFFICIENT      = 1 << 7,

        __WQ_DRAINING           = 1 << 16,
        __WQ_ORDERED            = 1 << 17,

        WQ_MAX_ACTIVE           = 512,
        WQ_MAX_UNBOUND_PER_CPU  = 4,
        WQ_DFL_ACTIVE           = WQ_MAX_ACTIVE / 2,
}; extern struct workqueue_struct *system_wq;
extern struct workqueue_struct *system_highpri_wq;
extern struct workqueue_struct
        """
        actual = trimming_parser.build_snippets(source)
        # Make sure $VARS is filled in with the global values.
        self.assertEqual(len(actual["$VARS"]), 12)
        self.assertEqual(actual["$VARS"]["WQ_POWER_EFFICIENT"],
                         c_ast.CFunctionCall(
                             function_name="<<",
                             arguments=[
                                 c_ast.CNumber(1),
                                 c_ast.CNumber(7)
                             ]
                         ))

        # Ensure that a new anonymous enum is added to the snippets.
        self.assertEqual(set(actual.keys()),
                         set(['enum __unknown_enum_1', '$VARS']))
Пример #4
0
    def test_anonymous_enum(self):
        source = """
        struct work_struct work;
}; enum {
        WQ_UNBOUND              = 1 << 1,
        WQ_FREEZABLE            = 1 << 2,
        WQ_MEM_RECLAIM          = 1 << 3,
        WQ_HIGHPRI              = 1 << 4,
        WQ_CPU_INTENSIVE        = 1 << 5,
        WQ_SYSFS                = 1 << 6,


        WQ_POWER_EFFICIENT      = 1 << 7,

        __WQ_DRAINING           = 1 << 16,
        __WQ_ORDERED            = 1 << 17,

        WQ_MAX_ACTIVE           = 512,
        WQ_MAX_UNBOUND_PER_CPU  = 4,
        WQ_DFL_ACTIVE           = WQ_MAX_ACTIVE / 2,
}; extern struct workqueue_struct *system_wq;
extern struct workqueue_struct *system_highpri_wq;
extern struct workqueue_struct
        """
        actual = trimming_parser.build_snippets(source)
        # Make sure $VARS is filled in with the global values.
        self.assertEqual(len(actual["$VARS"]), 12)
        self.assertEqual(
            actual["$VARS"]["WQ_POWER_EFFICIENT"],
            c_ast.CFunctionCall(function_name="<<",
                                arguments=[c_ast.CNumber(1),
                                           c_ast.CNumber(7)]))

        # Ensure that a new anonymous enum is added to the snippets.
        self.assertEqual(set(actual.keys()),
                         set(['enum __unknown_enum_1', '$VARS']))
Пример #5
0
 def test_pointer_typedef(self):
     source = """
     typedef __signalfn_t  * __sighandler_t ;
     """
     actual = trimming_parser.build_snippets(source)
     self.assertTrue("__sighandler_t" in actual)
Пример #6
0
 def test_pointer_typedef(self):
     source = """
     typedef __signalfn_t  * __sighandler_t ;
     """
     actual = trimming_parser.build_snippets(source)
     self.assertTrue("__sighandler_t" in actual)