static debuginfod_client *client;
static int verbose;
static volatile sig_atomic_t interrupted;
+static bool saw_progress_envvar;
static void
handle_sigint(int signo __attribute__((__unused__)))
interrupted = 1;
}
-int progressfn(debuginfod_client *c __attribute__((__unused__)),
- long a, long b)
+static int
+progressfn(debuginfod_client *c, long a, long b)
{
if (interrupted)
return 1;
if (verbose < 1)
- return 0;
+ {
+ /* Fallback to the default progressfn if verbose isn't set and
+ DEBUGINFOD_PROGRESS is set. */
+ if (saw_progress_envvar)
+ return debuginfod_default_progressfn (c, a, b);
+ return 0;
+ }
static bool first = true;
static struct timespec last;
sa.sa_handler = handle_sigint;
sigaction (SIGINT, &sa, NULL);
+ if (getenv(DEBUGINFOD_PROGRESS_ENV_VAR) != NULL)
+ saw_progress_envvar = true;
+
debuginfod_set_progressfn (client, & progressfn);
/* Exercise user data pointer, to support testing only. */
filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c`
cmp $filename ${PWD}/prog2.c
+# Check that debuginfod-find with DEBUGINFOD_PROGRESS set and no -v uses
+# libdebuginfod's default progress callback function
+rm -rf $DEBUGINFOD_CACHE_PATH/$BUILDID2/executable
+filename=`testrun env DEBUGINFOD_PROGRESS=1 ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2 2>vlog2`
+grep -q 'Downloading.*http' vlog2
kill $PID1
wait $PID1