mirror of
https://git.code.sf.net/p/zint/code
synced 2025-06-02 16:09:51 -04:00
test_output BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF: skip read-only test if root (ticket #274)
This commit is contained in:
parent
831c704b7b
commit
2230c3a2ec
8 changed files with 88 additions and 40 deletions
|
@ -178,6 +178,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle);
|
|||
|
||||
static void test_outfile(const testCtx *const p_ctx) {
|
||||
int ret;
|
||||
int skip_readonly_test = 0;
|
||||
struct zint_symbol symbol = {0};
|
||||
struct zint_vector vector = {0};
|
||||
|
||||
|
@ -189,12 +190,17 @@ static void test_outfile(const testCtx *const p_ctx) {
|
|||
symbol.vector = &vector;
|
||||
|
||||
strcpy(symbol.outfile, "test_emf_out.emf");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "emf_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
#ifndef _WIN32
|
||||
skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */
|
||||
#endif
|
||||
if (!skip_readonly_test) {
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "emf_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = emf_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "emf_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "emf_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
ret = emf_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "emf_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "emf_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue