[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] test-logging: don't hard-code paths in /tmp
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH] test-logging: don't hard-code paths in /tmp |
Date: |
Tue, 16 Aug 2016 17:15:07 +0100 |
On 15 August 2016 at 19:24, Sascha Silbe <address@hidden> wrote:
> Peter Maydell <address@hidden> writes:
>> On 15 July 2016 at 17:24, Sascha Silbe <address@hidden> wrote:
> [...]
>>> +static void rmtree(gchar const *root)
> [...]
>> I don't really like spawning rm here for this. We know we
>> don't have any subdirectories here so we can just
>> gdir = g_dir_open(root, 0, NULL);
>> for (;;) {
>> const char *f = g_dir_read_name(gdir);
>> if (!f) {
>> break;
>> }
>> g_remove(f);
>> }
>> g_dir_close(gdir);
>> g_rmdir(root);
>>
>> (add error handling to taste).
>
> I don't really like the rm spawning solution either. But the above plus
> error handling was a bit much for a single test for my taste.
>
> Is there some place I could stick something like the above so it could
> at least be reused by other tests in the future? (Even though I very
> much hate the idea of implementing yet another rmtree()).
tests/libqtest.c is probably as good a place as any.
> [...]
>>> int main(int argc, char **argv)
>>> {
>>> + gchar *tmp_path = g_dir_make_tmp("qemu-test-logging.XXXXXX", NULL);
>>
>> Unfortunately g_dir_make_tmp() only came in in glib 2.30, and we have
>> to be able to build with glib 2.22.
>
> Bummer. The old interfaces were really awkward. Is there somewhere I
> could put a compatibility wrapper, implementing g_dir_make_tmp() using
> the old interfaces?
include/glib-compat.h is where we provide compatible reimplementations
of glib function for older setups.
thanks
-- PMM