[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tests: Make test suite work out of the box on Debian


On Wednesday 16 March 2016 12:32:29 Justus Winter wrote:
> * tests/torture.c (torture_setup_create_sshd_config): Rework how the
> location of the sftp server is discovered, and add the Debian-specific
> location.

Are you fine with the attached modification?

Cheers,


	-- andreas

> 
> Signed-off-by: Justus Winter <justus@xxxxxxxxxxx>
> ---
>  tests/torture.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/tests/torture.c b/tests/torture.c
> index dd958c6..2701042 100644
> --- a/tests/torture.c
> +++ b/tests/torture.c
> @@ -858,6 +858,13 @@ static void torture_setup_create_sshd_config(void
> **state) struct stat sb;
>      const char *sftp_server;
>      int rc;
> +    const char **loc, *sftp_server_locations[] = {
> +        "/usr/lib/ssh/sftp-server",
> +        "/usr/libexec/sftp-server",
> +        "/usr/libexec/openssh/sftp-server",
> +        "/usr/lib/openssh/sftp-server",		/* Debian */
> +        NULL
> +    };
> 
>      snprintf(sshd_path,
>               sizeof(sshd_path),
> @@ -888,19 +895,13 @@ static void torture_setup_create_sshd_config(void
> **state)
> 
>      assert_non_null(s->socket_dir);
> 
> -    sftp_server = "/usr/lib/ssh/sftp-server";
> -    rc = lstat(sftp_server, &sb);
> -    if (rc < 0) {
> -        sftp_server = "/usr/libexec/sftp-server";
> +    for (loc = sftp_server_locations; (sftp_server = *loc); loc++) {
>          rc = lstat(sftp_server, &sb);
> -        if (rc < 0) {
> -            sftp_server = "/usr/libexec/openssh/sftp-server";
> -            rc = lstat(sftp_server, &sb);
> -            if (rc < 0) {
> -                sftp_server = getenv("TORTURE_SFTP_SERVER");
> -            }
> -        }
> +        if (rc == 0)
> +            break;
>      }
> +    if (sftp_server == NULL)
> +        sftp_server = getenv("TORTURE_SFTP_SERVER");
>      assert_non_null(sftp_server);
> 
>      snprintf(sshd_config, sizeof(sshd_config),

-- 
Andreas Schneider                   GPG-ID: CC014E3D
www.cryptomilk.org                asn@xxxxxxxxxxxxxx
From 861a1005ecda4ecd5db437916cb3308f8a596e4e Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@xxxxxxxxxxx>
Date: Wed, 16 Mar 2016 12:32:29 +0100
Subject: [PATCH] tests: Make test suite work out of the box on Debian

* tests/torture.c (torture_setup_create_sshd_config): Rework how the
location of the sftp server is discovered, and add the Debian-specific
location.

Signed-off-by: Justus Winter <justus@xxxxxxxxxxx>
---
 tests/torture.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/tests/torture.c b/tests/torture.c
index 5ee95b6..8921e9e 100644
--- a/tests/torture.c
+++ b/tests/torture.c
@@ -866,7 +866,15 @@ static void torture_setup_create_sshd_config(void **state)
     char sshd_config[2048];
     char sshd_path[1024];
     struct stat sb;
+    const char *sftp_server_locations[] = {
+        "/usr/lib/ssh/sftp-server",
+        "/usr/libexec/sftp-server",
+        "/usr/libexec/openssh/sftp-server",
+        "/usr/lib/openssh/sftp-server",     /* Debian */
+    };
+    size_t sftp_sl_size = ARRAY_SIZE(sftp_server_locations);
     const char *sftp_server;
+    size_t i;
     int rc;
 
     snprintf(sshd_path,
@@ -904,16 +912,13 @@ static void torture_setup_create_sshd_config(void **state)
 
     assert_non_null(s->socket_dir);
 
-    sftp_server = "/usr/lib/ssh/sftp-server";
-    rc = lstat(sftp_server, &sb);
-    if (rc < 0) {
-        sftp_server = "/usr/libexec/sftp-server";
-        rc = lstat(sftp_server, &sb);
-        if (rc < 0) {
-            sftp_server = "/usr/libexec/openssh/sftp-server";
+    sftp_server = getenv("TORTURE_SFTP_SERVER");
+    if (sftp_server == NULL) {
+        for (i = 0; i < sftp_sl_size; i++) {
+            sftp_server = sftp_server_locations[i];
             rc = lstat(sftp_server, &sb);
-            if (rc < 0) {
-                sftp_server = getenv("TORTURE_SFTP_SERVER");
+            if (rc == 0) {
+                break;
             }
         }
     }
-- 
2.7.4


Follow-Ups:
Re: [PATCH] tests: Make test suite work out of the box on DebianJustus Winter <justus@xxxxxxxxxxx>
References:
[PATCH] tests: Make test suite work out of the box on DebianJustus Winter <justus@xxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org