From 69294ef3439774ea581a0c5028c610576f61da5b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 7 Aug 2024 13:08:35 -0400 Subject: [PATCH] add "verbose" option for debugging which will divert libcurl logging to the screen --- src/EXTRA-COMMAND/geturl.cpp | 11 +++++++++-- unittest/commands/test_simple_commands.cpp | 3 +-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/EXTRA-COMMAND/geturl.cpp b/src/EXTRA-COMMAND/geturl.cpp index 3350b18455..106abb19d4 100644 --- a/src/EXTRA-COMMAND/geturl.cpp +++ b/src/EXTRA-COMMAND/geturl.cpp @@ -36,6 +36,7 @@ void GetURL::command(int narg, char **arg) if (narg < 1) utils::missing_cmd_args(FLERR, "geturl", error); int verify = 1; int overwrite = 1; + int verbose = 0; // process arguments @@ -63,6 +64,10 @@ void GetURL::command(int narg, char **arg) if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "geturl verify", error); verify = utils::logical(FLERR, arg[iarg + 1], false, lmp); ++iarg; + } else if (strcmp(arg[iarg], "verbose") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "geturl verbose", error); + verbose = utils::logical(FLERR, arg[iarg + 1], false, lmp); + ++iarg; } else { error->all(FLERR, "Unknown geturl keyword: {}", arg[iarg]); } @@ -91,8 +96,10 @@ void GetURL::command(int narg, char **arg) curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) out); curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - + if (verbose && screen) { + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_STDERR, (void *) screen); + } if (!verify) { curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp index 017d7ee870..d3fef447ac 100644 --- a/unittest/commands/test_simple_commands.cpp +++ b/unittest/commands/test_simple_commands.cpp @@ -36,7 +36,7 @@ #include // whether to print verbose output (i.e. not capturing LAMMPS screen output). -bool verbose = true; +bool verbose = false; namespace LAMMPS_NS { using ::testing::ContainsRegex; @@ -565,7 +565,6 @@ TEST_F(SimpleCommandsTest, Geturl) platform::unlink("myindex.html"); if (Info::has_curl_support()) { BEGIN_CAPTURE_OUTPUT(); - command("shell curl -v -o myindex.html https://www.lammps.org/index.html"); command("geturl https://www.lammps.org/index.html"); command("geturl https://www.lammps.org/index.html output myindex.html"); END_CAPTURE_OUTPUT();