-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unit tests for rgpgfs_fs_mkdirs; docker ignore binaries in src/…
… & tests/
- Loading branch information
1 parent
d6fe4ab
commit a31c36f
Showing
4 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
* | ||
!Makefile | ||
!docker/ | ||
!src/ | ||
!tests/ | ||
!src/*.c | ||
!src/*.h | ||
!tests/*.c | ||
|
||
# https://docs.docker.com/engine/reference/builder/#dockerignore-file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "src/fs.h" | ||
|
||
#define _GNU_SOURCE | ||
#include <errno.h> | ||
#include <ftw.h> | ||
|
||
#include <assert.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#define PATH_BUF_LEN 256 | ||
|
||
void test_mkdirs(const char *temp_dir, const char *rel_path) { | ||
char abs_path[PATH_BUF_LEN]; | ||
strcpy(abs_path, temp_dir); | ||
strcat(abs_path, "/"); | ||
strcat(abs_path, rel_path); | ||
if (rgpgfs_fs_mkdirs(abs_path)) { | ||
fprintf(stderr, "rel_path = '%s'\n", rel_path); | ||
perror("rgpgfs_fs_mkdirs failed"); | ||
exit(1); | ||
} | ||
|
||
FILE *f = fopen(abs_path, "w"); | ||
assert(f); | ||
fclose(f); | ||
}; | ||
|
||
int cleanup_rm_cb(const char *fpath, const struct stat *sb, int typeflag, | ||
struct FTW *ftwbuf) { | ||
if (remove(fpath)) { | ||
perror(fpath); | ||
} | ||
return 0; | ||
} | ||
|
||
int main() { | ||
char temp_dir[] = "/tmp/rgpgfs-tests-fs-XXXXXX"; | ||
assert(mkdtemp(temp_dir)); | ||
// printf("temp dir: %s\n", temp_dir); | ||
|
||
test_mkdirs(temp_dir, "file"); | ||
test_mkdirs(temp_dir, "a/file"); | ||
test_mkdirs(temp_dir, "a/b/file"); | ||
test_mkdirs(temp_dir, "c/d/file"); | ||
|
||
nftw(temp_dir, cleanup_rm_cb, 8, FTW_DEPTH); | ||
return 0; | ||
} |