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:
parent
831c704b7b
commit
2230c3a2ec
@ -231,6 +231,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" };
|
||||
|
||||
@ -243,12 +244,17 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "test_bmp_out.bmp");
|
||||
#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), "bmp_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = bmp_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "bmp_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "bmp_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -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");
|
||||
#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));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -271,6 +271,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" };
|
||||
|
||||
@ -283,12 +284,17 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "test_gif_out.gif");
|
||||
#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), "gif_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = gif_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "gif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "gif_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -146,6 +146,7 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
||||
|
||||
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" };
|
||||
|
||||
@ -158,12 +159,17 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "test_pcx_out.pcx");
|
||||
#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), "pcx_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = pcx_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "pcx_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "pcx_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -310,6 +310,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" };
|
||||
|
||||
@ -322,12 +323,17 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.bitmap_width = symbol.bitmap_height = 1;
|
||||
|
||||
strcpy(symbol.outfile, "test_png_out.png");
|
||||
#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), "png_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = png_pixel_plot(&symbol, data);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "png_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "png_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -214,6 +214,7 @@ INTERNAL int ps_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};
|
||||
|
||||
@ -225,12 +226,17 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.vector = &vector;
|
||||
|
||||
strcpy(symbol.outfile, "test_ps_out.eps");
|
||||
#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), "ps_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = ps_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "ps_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "ps_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -222,6 +222,7 @@ INTERNAL int svg_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};
|
||||
|
||||
@ -233,12 +234,17 @@ static void test_outfile(const testCtx *const p_ctx) {
|
||||
symbol.vector = &vector;
|
||||
|
||||
strcpy(symbol.outfile, "test_svg_out.svg");
|
||||
#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), "svg_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
|
||||
ret = svg_plot(&symbol, 0);
|
||||
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "svg_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
|
||||
assert_zero(testUtilRmROFile(symbol.outfile), "svg_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
@ -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");
|
||||
#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));
|
||||
}
|
||||
|
||||
symbol.output_options |= BARCODE_STDOUT;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user