def test_probes_struct_pointer_type_serialization(self): # given type = "foo_t *" accessor = "self->arg0" types = { "float": { "printf_specifier": "%f", "native": True }, "int": { "printf_specifier": "%f", "native": True }, "foo_t": { "native": False, "struct": { "value_f": "float", "value_int": "int *" } } } # when output = serialize_struct_type(type, accessor, types) # then self.assertEqual( "!!(((foo_t *)(self->arg0))->value_int) ? (int)0 : *(int *)copyin((uint64_t)((foo_t *)(self->arg0))->value_int, sizeof(int)), (float)(((foo_t *)(self->arg0))->value_f)", output)
def test_probes_struct_pointer_type_serialization(self): # given type = "foo_t *" accessor = "self->arg0" types = { "float": { "printf_specifier": "%f", "native": True }, "int": { "printf_specifier": "%f", "native": True }, "foo_t": { "native": False, "struct": { "value_f": "float", "value_int": "int *" } } } # when output = serialize_struct_type(type, accessor, types) # then self.assertEqual( "!!(((foo_t *)(self->arg0))->value_int) ? (int)0 : *(int *)copyin((uint64_t)((foo_t *)(self->arg0))->value_int, sizeof(int)), (float)(((foo_t *)(self->arg0))->value_f)", output )
def test_probes_struct_type_serialization(self): # given type = "foo_t" accessor = "self->arg0" types = { "float": { "printf_specifier": "%f", "native": True }, "char *": { "printf_specifier": '"%S"', "native": True, "template": '!!(${ARG}) ? copyinstr((uint64_t)${ARG}) : "<NULL>"' }, "foo_t": { "native": False, "struct": { "value_f": "float", "value_str": "char *" } } } # when output = serialize_struct_type(type, accessor, types) # then self.assertEqual( '(float)(((foo_t)(self->arg0)).value_f), !!(((foo_t)(self->arg0)).value_str) ? copyinstr((uint64_t)((foo_t)(self->arg0)).value_str) : "<NULL>"', output)
def test_probes_struct_type_serialization(self): # given type = "foo_t" accessor = "self->arg0" types = { "float": { "printf_specifier": "%f", "native": True }, "char *": { "printf_specifier": '"%S"', "native": True, "template": '!!(${ARG}) ? copyinstr((uint64_t)${ARG}) : "<NULL>"' }, "foo_t": { "native": False, "struct": { "value_f": "float", "value_str": "char *" } } } # when output = serialize_struct_type(type, accessor, types) # then self.assertEqual( '(float)(((foo_t)(self->arg0)).value_f), !!(((foo_t)(self->arg0)).value_str) ? copyinstr((uint64_t)((foo_t)(self->arg0)).value_str) : "<NULL>"', output )