diff options
author | Daiki Ueno <dueno@redhat.com> | 2018-02-27 14:57:20 +0100 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2018-02-27 16:33:59 +0100 |
commit | d8acebf175d727a3e146956fb362c30e7fdec9df (patch) | |
tree | 985a8ec7908014692d47972e48e6e508de73a29d /common | |
parent | bcf2c4e0a24303f976dbedc0ef0a564b9808a989 (diff) |
common: Make p11_test_directory_delete() work recursively
Diffstat (limited to 'common')
-rw-r--r-- | common/test.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/common/test.c b/common/test.c index 86c8c52..e917701 100644 --- a/common/test.c +++ b/common/test.c @@ -430,6 +430,8 @@ p11_test_directory_delete (const char *directory) { struct dirent *dp; DIR *dir; + char *path; + struct stat st; dir = opendir (directory); if (dir == NULL) { @@ -442,7 +444,15 @@ p11_test_directory_delete (const char *directory) strcmp (dp->d_name, "..") == 0) continue; - p11_test_file_delete (directory, dp->d_name); + if (asprintf (&path, "%s/%s", directory, dp->d_name) < 0) + assert_not_reached (); + if (stat (path, &st) < 0) + assert_not_reached (); + if (S_ISDIR (st.st_mode)) + p11_test_directory_delete (path); + else + p11_test_file_delete (directory, dp->d_name); + free (path); } closedir (dir); |