public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage-utils:master commit in: /, tests/qcheck/
@ 2015-06-06  6:20 Mike Frysinger
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2015-06-06  6:20 UTC (permalink / raw
  To: gentoo-commits

commit:     432dc6f0189116a0b3aece01ac013b1bee3ce778
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  6 05:58:21 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Jun  6 05:58:21 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=432dc6f0

Revert "tests: qcheck: tweak some tests output"

This reverts commit 0c7050208c110faac5dd54a452ed60a7a40eae07.

Trying to get stable output with multiple packages was getting to be too
much of a pain, and sorting the output arbitrarily didn't feel correct
either.  Bite the bullet and have qcheck sort its walking of the vdb.

URL: https://bugs.gentoo.org/549934
Reported-by: Patrick Lauer <patrick <AT> gentoo.org>

 qcheck.c                 |  2 +-
 tests/qcheck/dotest      | 11 ++++-------
 tests/qcheck/list04.good |  4 ++--
 tests/qcheck/list05.good |  4 ++--
 tests/qcheck/list06.good |  4 ++--
 tests/qcheck/list07.good |  4 ++--
 6 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index 75dbf6d..6ad5f85 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -399,7 +399,7 @@ int qcheck_main(int argc, char **argv)
 	if ((argc == optind) && !state.search_all)
 		qcheck_usage(EXIT_FAILURE);
 
-	ret = q_vdb_foreach_pkg(qcheck_cb, &state, NULL);
+	ret = q_vdb_foreach_pkg_sorted(qcheck_cb, &state);
 	xarrayfree(regex_arr);
 	return ret;
 }

diff --git a/tests/qcheck/dotest b/tests/qcheck/dotest
index 016fd10..965a5b5 100755
--- a/tests/qcheck/dotest
+++ b/tests/qcheck/dotest
@@ -28,9 +28,6 @@ test() {
 	tend $? "$*"
 }
 
-# have to avoid the -a flag and walk one package at a time as qcheck does not
-# sort the vdb dirs before processing them.
-
 # simple check
 test 01 1 "qcheck a-b/pkg"
 
@@ -41,16 +38,16 @@ test 02 1 "qcheck a-b/pkg -s ^/missing-dir/.*"
 test 03 1 "qcheck -Ba"
 
 # hash mismatch ignore check
-test 04 1 "qcheck -H cat/pkg && qcheck -H a-b/pkg"
+test 04 1 "qcheck -Ha"
 
 # mtime mismatch ignore check
-test 05 1 "qcheck -T cat/pkg && qcheck -T a-b/pkg"
+test 05 1 "qcheck -Ta"
 
 # missing ignore check
-test 06 1 "qcheck -A cat/pkg && qcheck -A a-b/pkg"
+test 06 1 "qcheck -Aa"
 
 # hash+mtime+missing mismatch ignore check
-test 07 0 "qcheck -AHT cat/pkg && qcheck -AHT a-b/pkg"
+test 07 0 "qcheck -AHTa"
 
 # verbose check
 test 08 1 "qcheck -v a-b/pkg"

diff --git a/tests/qcheck/list04.good b/tests/qcheck/list04.good
index 943e0f5..930f896 100644
--- a/tests/qcheck/list04.good
+++ b/tests/qcheck/list04.good
@@ -1,5 +1,3 @@
-Checking cat/pkg-1 ...
-  * 0 out of 0 file are good
 Checking a-b/pkg-1.0 ...
  MTIME: /bin/bad-mtime-obj
  MTIME: /bin/bad-mtime-sym
@@ -9,3 +7,5 @@ Checking a-b/pkg-1.0 ...
  AFK: /missing-dir/missing-file
  AFK: /missing-dir/missing-sym
   * 4 out of 11 files are good (2 files were ignored)
+Checking cat/pkg-1 ...
+  * 0 out of 0 file are good

diff --git a/tests/qcheck/list05.good b/tests/qcheck/list05.good
index b1a8955..d4c4243 100644
--- a/tests/qcheck/list05.good
+++ b/tests/qcheck/list05.good
@@ -1,5 +1,3 @@
-Checking cat/pkg-1 ...
-  * 0 out of 0 file are good
 Checking a-b/pkg-1.0 ...
  MD5-DIGEST: /bin/bad-md5
  SHA1-DIGEST: /bin/bad-sha1
@@ -9,3 +7,5 @@ Checking a-b/pkg-1.0 ...
  AFK: /missing-dir/missing-file
  AFK: /missing-dir/missing-sym
   * 4 out of 11 files are good (2 files were ignored)
+Checking cat/pkg-1 ...
+  * 0 out of 0 file are good

diff --git a/tests/qcheck/list06.good b/tests/qcheck/list06.good
index 7b770a5..3cd48f7 100644
--- a/tests/qcheck/list06.good
+++ b/tests/qcheck/list06.good
@@ -1,8 +1,8 @@
-Checking cat/pkg-1 ...
-  * 0 out of 0 file are good
 Checking a-b/pkg-1.0 ...
  MD5-DIGEST: /bin/bad-md5
  MTIME: /bin/bad-mtime-obj
  SHA1-DIGEST: /bin/bad-sha1
  MTIME: /bin/bad-mtime-sym
   * 4 out of 8 files are good (5 files were ignored)
+Checking cat/pkg-1 ...
+  * 0 out of 0 file are good

diff --git a/tests/qcheck/list07.good b/tests/qcheck/list07.good
index 4a86950..fb59689 100644
--- a/tests/qcheck/list07.good
+++ b/tests/qcheck/list07.good
@@ -1,4 +1,4 @@
-Checking cat/pkg-1 ...
-  * 0 out of 0 file are good
 Checking a-b/pkg-1.0 ...
   * 4 out of 4 files are good (9 files were ignored)
+Checking cat/pkg-1 ...
+  * 0 out of 0 file are good


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/portage-utils:master commit in: /, tests/qcheck/
@ 2019-07-12 18:04 Fabian Groffen
  0 siblings, 0 replies; 3+ messages in thread
From: Fabian Groffen @ 2019-07-12 18:04 UTC (permalink / raw
  To: gentoo-commits

commit:     667a6170ad2536aa3800bf35b3ea38f227d739b7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 29 11:44:55 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jun 29 11:44:55 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=667a6170

qcheck: add -F argument

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 q.c                      |  2 +-
 qcheck.c                 | 38 ++++++++++++++++++++++----------------
 tests/qcheck/dotest      |  2 +-
 tests/qcheck/list01.good |  2 +-
 tests/qcheck/list02.good |  2 +-
 tests/qcheck/list04.good |  4 ++--
 tests/qcheck/list05.good |  4 ++--
 tests/qcheck/list06.good |  4 ++--
 tests/qcheck/list07.good |  4 ++--
 tests/qcheck/list09.good |  4 ++--
 10 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/q.c b/q.c
index 31427f3..3dd49f7 100644
--- a/q.c
+++ b/q.c
@@ -129,7 +129,7 @@ int q_main(int argc, char **argv)
 		rret = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
 #endif
 		if (rret == -1) {
-			warnfp("haha no symlink love for you");
+			warnfp("haha no symlink love for you ... :(");
 			return 1;
 		}
 		buf[rret] = '\0';

diff --git a/qcheck.c b/qcheck.c
index 97070f2..f77a501 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -24,8 +24,12 @@
 #include "xasprintf.h"
 #include "xregex.h"
 
-#define QCHECK_FLAGS "s:uABHTPp" COMMON_FLAGS
+#define QCHECK_FORMAT "%[CATEGORY]%[PN]"
+#define QCHECK_FORMAT_VERBOSE "%[CATEGORY]%[PF]"
+
+#define QCHECK_FLAGS "F:s:uABHTPp" COMMON_FLAGS
 static struct option const qcheck_long_opts[] = {
+	{"format",          a_argument, NULL, 'F'},
 	{"skip",            a_argument, NULL, 's'},
 	{"update",         no_argument, NULL, 'u'},
 	{"noafk",          no_argument, NULL, 'A'},
@@ -37,6 +41,7 @@ static struct option const qcheck_long_opts[] = {
 	COMMON_LONG_OPTS
 };
 static const char * const qcheck_opts_help[] = {
+	"Custom output format (default: " QCHECK_FORMAT ")",
 	"Ignore files matching the regular expression <arg>",
 	"Update missing files, chksum and mtimes for packages",
 	"Ignore missing files",
@@ -61,6 +66,7 @@ struct qcheck_opt_state {
 	bool chk_mtime;
 	bool chk_config_protect;
 	bool undo_prelink;
+	const char *fmt;
 };
 
 static int
@@ -97,7 +103,7 @@ qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 	num_files = num_files_ok = num_files_unknown = num_files_ignored = 0;
 	qcprintf("%sing %s ...\n",
 		(state->qc_update ? "Updat" : "Check"),
-		atom_format("%[CATEGORY]%[PF]", atom));
+		atom_format(state->fmt, atom));
 	if (state->qc_update) {
 		fp_contents_update = tree_pkg_vdb_fopenat_rw(pkg_ctx, "CONTENTS~");
 		if (fp_contents_update == NULL) {
@@ -328,13 +334,8 @@ qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 		if (!verbose)
 			return EXIT_SUCCESS;
 	}
-	if (state->bad_only && num_files_ok != num_files) {
-		if (verbose)
-			printf("%s\n", atom_format("%[CATEGORY]%[PF]", atom));
-		else {
-			printf("%s\n", atom_format("%[CATEGORY]%[PN]", atom));
-		}
-	}
+	if (state->bad_only && num_files_ok != num_files)
+		printf("%s\n", atom_format(state->fmt, atom));
 	qcprintf("  %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good",
 		NORM, BOLD, BLUE, num_files_ok, num_files,
 		(num_files > 1 ? "s" : ""));
@@ -398,6 +399,7 @@ int qcheck_main(int argc, char **argv)
 		.chk_mtime = true,
 		.chk_config_protect = true,
 		.undo_prelink = false,
+		.fmt = NULL,
 	};
 
 	while ((ret = GETOPT_LONG(QCHECK, qcheck, "")) != -1) {
@@ -409,16 +411,20 @@ int qcheck_main(int argc, char **argv)
 			xarraypush(regex_arr, &preg, sizeof(preg));
 			break;
 		}
-		case 'u': state.qc_update = true; break;
-		case 'A': state.chk_afk = false; break;
-		case 'B': state.bad_only = true; break;
-		case 'H': state.chk_hash = false; break;
-		case 'T': state.chk_mtime = false; break;
-		case 'P': state.chk_config_protect = false; break;
-		case 'p': state.undo_prelink = prelink_available(); break;
+		case 'u': state.qc_update = true;                    break;
+		case 'A': state.chk_afk = false;                     break;
+		case 'B': state.bad_only = true;                     break;
+		case 'H': state.chk_hash = false;                    break;
+		case 'T': state.chk_mtime = false;                   break;
+		case 'P': state.chk_config_protect = false;          break;
+		case 'p': state.undo_prelink = prelink_available();  break;
+		case 'F': state.fmt = optarg;                        break;
 		}
 	}
 
+	if (state.fmt == NULL)
+		state.fmt = verbose ? QCHECK_FORMAT_VERBOSE : QCHECK_FORMAT;
+
 	argc -= optind;
 	argv += optind;
 	for (i = 0; i < (size_t)argc; ++i) {

diff --git a/tests/qcheck/dotest b/tests/qcheck/dotest
index fa1feed..c6e6e46 100755
--- a/tests/qcheck/dotest
+++ b/tests/qcheck/dotest
@@ -19,7 +19,7 @@ test() {
 	local num=$1 exp=$2 ret=0
 	shift 2
 	eval "$@" > list || ret=$?
-	if ! diff -u list ${as}/list${num}.good ; then
+	if ! diff -u ${as}/list${num}.good list ; then
 		tfail "output does not match"
 	fi
 	if [[ ${exp} -ne ${ret} ]] ; then

diff --git a/tests/qcheck/list01.good b/tests/qcheck/list01.good
index 71e9db3..a6bde03 100644
--- a/tests/qcheck/list01.good
+++ b/tests/qcheck/list01.good
@@ -1,4 +1,4 @@
-Checking a-b/pkg-1.0 ...
+Checking a-b/pkg ...
  MD5-DIGEST: /bin/bad-md5
  MTIME: /bin/bad-mtime-obj
  SHA1-DIGEST: /bin/bad-sha1

diff --git a/tests/qcheck/list02.good b/tests/qcheck/list02.good
index 8689d41..74e7b02 100644
--- a/tests/qcheck/list02.good
+++ b/tests/qcheck/list02.good
@@ -1,4 +1,4 @@
-Checking a-b/pkg-1.0 ...
+Checking a-b/pkg ...
  MD5-DIGEST: /bin/bad-md5
  MTIME: /bin/bad-mtime-obj
  SHA1-DIGEST: /bin/bad-sha1

diff --git a/tests/qcheck/list04.good b/tests/qcheck/list04.good
index b90a759..604d20c 100644
--- a/tests/qcheck/list04.good
+++ b/tests/qcheck/list04.good
@@ -1,4 +1,4 @@
-Checking a-b/pkg-1.0 ...
+Checking a-b/pkg ...
  MTIME: /bin/bad-mtime-obj
  MTIME: /bin/bad-mtime-sym
  AFK: /bin/broken-sym
@@ -7,5 +7,5 @@ Checking a-b/pkg-1.0 ...
  AFK: /missing-dir/missing-file
  AFK: /missing-dir/missing-sym
   * 4 out of 11 files are good (2 files were ignored)
-Checking virtual/pkg-1 ...
+Checking virtual/pkg ...
   * 0 out of 0 file are good

diff --git a/tests/qcheck/list05.good b/tests/qcheck/list05.good
index 6a6d206..35a0ff5 100644
--- a/tests/qcheck/list05.good
+++ b/tests/qcheck/list05.good
@@ -1,4 +1,4 @@
-Checking a-b/pkg-1.0 ...
+Checking a-b/pkg ...
  MD5-DIGEST: /bin/bad-md5
  SHA1-DIGEST: /bin/bad-sha1
  AFK: /bin/broken-sym
@@ -7,5 +7,5 @@ Checking a-b/pkg-1.0 ...
  AFK: /missing-dir/missing-file
  AFK: /missing-dir/missing-sym
   * 4 out of 11 files are good (2 files were ignored)
-Checking virtual/pkg-1 ...
+Checking virtual/pkg ...
   * 0 out of 0 file are good

diff --git a/tests/qcheck/list06.good b/tests/qcheck/list06.good
index a924758..fb241db 100644
--- a/tests/qcheck/list06.good
+++ b/tests/qcheck/list06.good
@@ -1,8 +1,8 @@
-Checking a-b/pkg-1.0 ...
+Checking a-b/pkg ...
  MD5-DIGEST: /bin/bad-md5
  MTIME: /bin/bad-mtime-obj
  SHA1-DIGEST: /bin/bad-sha1
  MTIME: /bin/bad-mtime-sym
   * 4 out of 8 files are good (5 files were ignored)
-Checking virtual/pkg-1 ...
+Checking virtual/pkg ...
   * 0 out of 0 file are good

diff --git a/tests/qcheck/list07.good b/tests/qcheck/list07.good
index f354269..ae80975 100644
--- a/tests/qcheck/list07.good
+++ b/tests/qcheck/list07.good
@@ -1,4 +1,4 @@
-Checking a-b/pkg-1.0 ...
+Checking a-b/pkg ...
   * 4 out of 4 files are good (9 files were ignored)
-Checking virtual/pkg-1 ...
+Checking virtual/pkg ...
   * 0 out of 0 file are good

diff --git a/tests/qcheck/list09.good b/tests/qcheck/list09.good
index cd6195e..a12d957 100644
--- a/tests/qcheck/list09.good
+++ b/tests/qcheck/list09.good
@@ -1,4 +1,4 @@
-Updating a-b/pkg-1.0 ...
+Updating a-b/pkg ...
  MD5-DIGEST: /bin/bad-md5
  MTIME: /bin/bad-mtime-obj
  SHA1-DIGEST: /bin/bad-sha1
@@ -8,5 +8,5 @@ Updating a-b/pkg-1.0 ...
  AFK: /missing-dir
  AFK: /missing-dir/missing-file
  AFK: /missing-dir/missing-sym
-Checking a-b/pkg-1.0 ...
+Checking a-b/pkg ...
   * 8 out of 8 files are good


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/portage-utils:master commit in: /, tests/qcheck/
@ 2020-01-02 15:23 Fabian Groffen
  0 siblings, 0 replies; 3+ messages in thread
From: Fabian Groffen @ 2020-01-02 15:23 UTC (permalink / raw
  To: gentoo-commits

commit:     6d6d693b3e0cd3aa6ea19ffe036e5f50c15aa7dd
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 15:22:52 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 15:22:52 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6d6d693b

qcheck: fix tests

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcheck.c                 | 5 +++--
 tests/qcheck/list04.good | 2 +-
 tests/qcheck/list05.good | 2 +-
 tests/qcheck/list06.good | 2 +-
 tests/qcheck/list07.good | 2 +-
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index e8db1b8..1217a8a 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -346,7 +346,7 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			(num_files_ignored > 1 ? "s were" : " was"));
 	qcprintf("\n");
 
-	if (num_files_ok != num_files)
+	if (num_files_ok != num_files && !state->qc_update)
 		return EXIT_FAILURE;
 	else
 		return EXIT_SUCCESS;
@@ -410,6 +410,7 @@ int qcheck_main(int argc, char **argv)
 	ret = -1;
 	if (vdb != NULL) {
 		if (array_cnt(atoms) != 0) {
+			ret = 0;
 			array_for_each(atoms, i, atom) {
 				ret |= tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, atom);
 			}
@@ -427,5 +428,5 @@ int qcheck_main(int argc, char **argv)
 	array_for_each(atoms, i, atom)
 		atom_implode(atom);
 	xarrayfree_int(atoms);
-	return ret;
+	return ret != 0;
 }

diff --git a/tests/qcheck/list04.good b/tests/qcheck/list04.good
index 604d20c..2f9f512 100644
--- a/tests/qcheck/list04.good
+++ b/tests/qcheck/list04.good
@@ -8,4 +8,4 @@ Checking a-b/pkg ...
  AFK: /missing-dir/missing-sym
   * 4 out of 11 files are good (2 files were ignored)
 Checking virtual/pkg ...
-  * 0 out of 0 file are good
+  * 0 out of 0 files are good

diff --git a/tests/qcheck/list05.good b/tests/qcheck/list05.good
index 35a0ff5..688c177 100644
--- a/tests/qcheck/list05.good
+++ b/tests/qcheck/list05.good
@@ -8,4 +8,4 @@ Checking a-b/pkg ...
  AFK: /missing-dir/missing-sym
   * 4 out of 11 files are good (2 files were ignored)
 Checking virtual/pkg ...
-  * 0 out of 0 file are good
+  * 0 out of 0 files are good

diff --git a/tests/qcheck/list06.good b/tests/qcheck/list06.good
index fb241db..6129032 100644
--- a/tests/qcheck/list06.good
+++ b/tests/qcheck/list06.good
@@ -5,4 +5,4 @@ Checking a-b/pkg ...
  MTIME: /bin/bad-mtime-sym
   * 4 out of 8 files are good (5 files were ignored)
 Checking virtual/pkg ...
-  * 0 out of 0 file are good
+  * 0 out of 0 files are good

diff --git a/tests/qcheck/list07.good b/tests/qcheck/list07.good
index ae80975..847b0b5 100644
--- a/tests/qcheck/list07.good
+++ b/tests/qcheck/list07.good
@@ -1,4 +1,4 @@
 Checking a-b/pkg ...
   * 4 out of 4 files are good (9 files were ignored)
 Checking virtual/pkg ...
-  * 0 out of 0 file are good
+  * 0 out of 0 files are good


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-02 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-02 15:23 [gentoo-commits] proj/portage-utils:master commit in: /, tests/qcheck/ Fabian Groffen
  -- strict thread matches above, loose matches on Subject: below --
2019-07-12 18:04 Fabian Groffen
2015-06-06  6:20 Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox