mirror of
https://github.com/intel/isa-l.git
synced 2025-01-31 10:31:12 +01:00
igzip: Implement --test option in igizp_cli
Change-Id: Iff64f591a77cc3aee775b6c30e97641f8d650e69 Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
parent
cd5de57f1f
commit
7177ff9966
@ -56,6 +56,9 @@ save/use file name and timestamp in compress/decompress
|
|||||||
\fB\-n\fR, \fB\-\-no\-name\fR
|
\fB\-n\fR, \fB\-\-no\-name\fR
|
||||||
do not save/use file name and timestamp in compress/decompress
|
do not save/use file name and timestamp in compress/decompress
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-t\fR, \fB\-\-test\fR
|
||||||
|
test compressed file integrity
|
||||||
|
.TP
|
||||||
\fB\-q\fR, \fB\-\-quiet\fR
|
\fB\-q\fR, \fB\-\-quiet\fR
|
||||||
suppress warnings
|
suppress warnings
|
||||||
.PP
|
.PP
|
||||||
|
@ -67,6 +67,9 @@
|
|||||||
#define NO_NAME 1
|
#define NO_NAME 1
|
||||||
#define YES_NAME 2
|
#define YES_NAME 2
|
||||||
|
|
||||||
|
#define NO_TEST 0
|
||||||
|
#define TEST 1
|
||||||
|
|
||||||
#define LEVEL_DEFAULT 2
|
#define LEVEL_DEFAULT 2
|
||||||
#define DEFAULT_SUFFIX_LEN 3
|
#define DEFAULT_SUFFIX_LEN 3
|
||||||
char *default_suffixes[] = { ".gz", ".z" };
|
char *default_suffixes[] = { ".gz", ".z" };
|
||||||
@ -159,6 +162,7 @@ struct cli_options {
|
|||||||
int quiet_level;
|
int quiet_level;
|
||||||
int verbose_level;
|
int verbose_level;
|
||||||
int name;
|
int name;
|
||||||
|
int test;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cli_options global_options;
|
struct cli_options global_options;
|
||||||
@ -180,6 +184,7 @@ void init_options(struct cli_options *options)
|
|||||||
options->verbose_level = 0;
|
options->verbose_level = 0;
|
||||||
options->verbose_level = 0;
|
options->verbose_level = 0;
|
||||||
options->name = NAME_DEFAULT;
|
options->name = NAME_DEFAULT;
|
||||||
|
options->test = NO_TEST;
|
||||||
};
|
};
|
||||||
|
|
||||||
int is_interactive(void)
|
int is_interactive(void)
|
||||||
@ -268,6 +273,7 @@ int usage(int exit_code)
|
|||||||
" -v, --verbose verbose mode\n"
|
" -v, --verbose verbose mode\n"
|
||||||
" -N, --name save/use file name and timestamp in compress/decompress\n"
|
" -N, --name save/use file name and timestamp in compress/decompress\n"
|
||||||
" -n, --no-name do not save/use file name and timestamp in compress/decompress\n"
|
" -n, --no-name do not save/use file name and timestamp in compress/decompress\n"
|
||||||
|
" -t, --test test compressed file integrity\n"
|
||||||
" -q, --quiet suppress warnings\n\n"
|
" -q, --quiet suppress warnings\n\n"
|
||||||
"with no infile, or when infile is - , read standard input\n\n",
|
"with no infile, or when infile is - , read standard input\n\n",
|
||||||
ISAL_DEF_MAX_LEVEL);
|
ISAL_DEF_MAX_LEVEL);
|
||||||
@ -574,7 +580,7 @@ int decompress_file(void)
|
|||||||
suffix_len = 0;
|
suffix_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (suffix == NULL) {
|
if (suffix == NULL && global_options.test == NO_TEST) {
|
||||||
log_print(ERROR, "igzip: %s: unknown suffix -- ignored\n",
|
log_print(ERROR, "igzip: %s: unknown suffix -- ignored\n",
|
||||||
infile_name);
|
infile_name);
|
||||||
return 1;
|
return 1;
|
||||||
@ -635,9 +641,11 @@ int decompress_file(void)
|
|||||||
goto decompress_file_cleanup;
|
goto decompress_file_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
open_out_file(&out, outfile_name);
|
if (global_options.test == NO_TEST) {
|
||||||
if (out == NULL)
|
open_out_file(&out, outfile_name);
|
||||||
goto decompress_file_cleanup;
|
if (out == NULL)
|
||||||
|
goto decompress_file_cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (state.avail_in == 0) {
|
if (state.avail_in == 0) {
|
||||||
@ -657,7 +665,8 @@ int decompress_file(void)
|
|||||||
goto decompress_file_cleanup;
|
goto decompress_file_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite_safe(outbuf, 1, state.next_out - outbuf, out, outfile_name);
|
if (out != NULL)
|
||||||
|
fwrite_safe(outbuf, 1, state.next_out - outbuf, out, outfile_name);
|
||||||
|
|
||||||
} while (!feof(in) || state.avail_out == 0);
|
} while (!feof(in) || state.avail_out == 0);
|
||||||
|
|
||||||
@ -695,7 +704,7 @@ int decompress_file(void)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
char optstring[] = "hcdz0123456789o:S:kfqVvNn";
|
char optstring[] = "hcdz0123456789o:S:kfqVvNnt";
|
||||||
int long_only_flag;
|
int long_only_flag;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int bad_option = 0;
|
int bad_option = 0;
|
||||||
@ -720,9 +729,8 @@ int main(int argc, char *argv[])
|
|||||||
{"verbose", no_argument, NULL, 'v'},
|
{"verbose", no_argument, NULL, 'v'},
|
||||||
{"no-name", no_argument, NULL, 'n'},
|
{"no-name", no_argument, NULL, 'n'},
|
||||||
{"name", no_argument, NULL, 'N'},
|
{"name", no_argument, NULL, 'N'},
|
||||||
|
{"test", no_argument, NULL, 't'},
|
||||||
/* Possible future extensions
|
/* Possible future extensions
|
||||||
{"test", no_argument, NULL, 't'},
|
|
||||||
{"recursive, no_argument, NULL, 'r'},
|
{"recursive, no_argument, NULL, 'r'},
|
||||||
{"check", no_argument, NULL, 'C'},
|
{"check", no_argument, NULL, 'C'},
|
||||||
{"no-check", no_argument, NULL, 0},
|
{"no-check", no_argument, NULL, 0},
|
||||||
@ -797,6 +805,10 @@ int main(int argc, char *argv[])
|
|||||||
case 'n':
|
case 'n':
|
||||||
global_options.name = NO_NAME;
|
global_options.name = NO_NAME;
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
global_options.test = TEST;
|
||||||
|
global_options.mode = DECOMPRESS_MODE;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(0);
|
usage(0);
|
||||||
default:
|
default:
|
||||||
|
@ -205,5 +205,14 @@ fi
|
|||||||
pass_check $ret "Decompress with name info"
|
pass_check $ret "Decompress with name info"
|
||||||
clear_dir
|
clear_dir
|
||||||
|
|
||||||
|
ret=0
|
||||||
|
cp -p $TEST_FILE $file1 && touch $file2\\
|
||||||
|
$IGZIP $file1 -o $file1$ds || ret=1
|
||||||
|
$IGZIP -t $file1$ds || ret=1
|
||||||
|
$IGZIP -t $file2 &> /dev/null && ret=1
|
||||||
|
cp $file1$ds $file2 && $IGZIP -t $file1$ds || ret=1
|
||||||
|
pass_check $ret "Test test"
|
||||||
|
clear_dir
|
||||||
|
|
||||||
echo "Passed all cli checks"
|
echo "Passed all cli checks"
|
||||||
cleanup 0
|
cleanup 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user