From d8acebf175d727a3e146956fb362c30e7fdec9df Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Tue, 27 Feb 2018 14:57:20 +0100 Subject: common: Make p11_test_directory_delete() work recursively --- common/test.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'common') 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); -- cgit v1.1