And fixing the munmap() being missing in read_from_spool_and_send_to_xen() reveals that xen_write_path->xs_write also stores 'buf'.. When you munmap() buf... The stored 'buf' in mock_xenstore points to bogus space.
So, obj->buf = buf; also needs to be fixed to malloc memory and memcpy.
And fixing the munmap() being missing in read_from_ spool_and_ send_to_ xen() reveals that xen_write_ path->xs_ write also stores 'buf'.. When you munmap() buf... The stored 'buf' in mock_xenstore points to bogus space.
So, obj->buf = buf; also needs to be fixed to malloc memory and memcpy.