]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
changes after review: updated comments and did other small improvements
authorMichal Nowikowski <godfryd@isc.org>
Thu, 7 Mar 2019 09:30:08 +0000 (10:30 +0100)
committerMichal Nowikowski <godfryd@isc.org>
Thu, 7 Mar 2019 09:59:29 +0000 (10:59 +0100)
ChangeLog
doc/devel/unit-tests.dox
src/lib/testutils/sandbox.h

index c085ff6c44341e0af47b1192f9288c629ca5982a..d16a5ea70c44d1657199701435fc6183ac151b67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+1537.  [func]          godfryd
+       Improved handling unix sockets in unit tests. Now by default
+       they are created in temporary folder under /tmp folder. This
+       fixes the issue with creating sockets with too long path
+       in the case when source folder is deeply nested.
+       (Gitlab #357,!258, git a45e2f68d7d1848adb0cf755954a3d76c9dff338)
+
 1536.  [build]         tomek
        Many changes in keactrl, kea-admin, cql_config and sysrepo_config
        scripts. ISC is now using shellcheck to verify portability of
index 937502ed828cf569c16f56432226b06fcd7f431d..a7edb9fa050c132ffe4cbf82fa8127ac17130bb7 100644 (file)
@@ -40,10 +40,9 @@ The following environment variable can affect the unit tests:
 - KEA_SOCKET_TEST_DIR - if set, it specifies the directory where Unix
   sockets are created. There is an operating system limitation on how
   long a Unix socket path can be, typically slightly over 100
-  characters. If you happen to build and run unit-tests in deeply nested
-  directories, this may become a problem. KEA_SOCKET_TEST_DIR can be
-  specified to instruct unit-test to use a different directory. It must
-  not end with slash.
+  characters. By default unit-tests create sockets in temporary folder
+  under /tmp folder. KEA_SOCKET_TEST_DIR can be specified to instruct
+  unit-tests to use a different directory. It must not end with slash.
 
 @section unitTestsDatabaseConfig Databases Configuration for Unit Tests
 
@@ -265,5 +264,5 @@ local   all             postgres                                trust
  [cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4 | Native protocol v4]
  Use HELP for help.
  cqlsh> @endverbatim\n
+
  */
index 115108e350a407622b7e7319699edee89cfbc735..13aab6ed5c1f565a69e630208625088a7240a509 100644 (file)
@@ -11,8 +11,9 @@
 
 #include <iostream>
 #include <string>
-#include <stdlib.h>
-#include <stdio.h>
+#include <cstdlib>
+#include <cstdio>
+#include <unistd.h>
 #include <ftw.h>
 
 namespace isc {
@@ -25,14 +26,12 @@ namespace test {
 /// in unit test setup phase, and then it is deleted with its content
 /// in destructor ie. in unit test tear down phase.
 class Sandbox {
+private:
     /// Path to temporary folder
     std::string path_;
 
     /// @brief Method for deleting files and folders, used in nftw traversal function.
-    static int rmFile(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) {
-        (void)sb;
-        (void)typeflag;
-        (void)ftwbuf;
+    static int rmFile(const char *fpath, const struct stat *, int , struct FTW *) {
         return(remove(fpath));
     }
 
@@ -51,9 +50,11 @@ public:
         }
     }
 
-    // @brief Join sandbox path with indicated file subpath.
+    /// @brief Join sandbox path with indicated file subpath.
+    ///
+    /// @param file A path to file that should be joined to base path of sandbox.
     std::string join(std::string file) {
-        return path_ + "/" + file;
+        return(path_ + "/" + file);
     }
 };