mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
test_output BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF: skip read-only test if root (ticket #274)
This commit is contained in:
@ -309,6 +309,7 @@ static void test_print(const testCtx *const p_ctx) {
|
||||
|
||||
static void test_outfile(const testCtx *const p_ctx) {
|
||||
int ret;
|
||||
int skip_readonly_test = 0;
|
||||
struct zint_symbol symbol = {0};
|
||||
unsigned char data[] = { "1" };
|
||||
|
||||
@ -321,12 +322,17 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "test_tif_out.tif");
|
||||
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
|
||||
assert_nonzero(testUtilCreateROFile(symbol.outfile), "tif_pixel_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), "tif_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = tif_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "tif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "tif_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
ret = tif_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "tif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "tif_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
Reference in New Issue
Block a user