Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/atf/dist Fix import conflicts for atf 0.9.



details:   https://anonhg.NetBSD.org/src/rev/a79a611669fb
branches:  trunk
changeset: 755391:a79a611669fb
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Fri Jun 04 08:32:14 2010 +0000

description:
Fix import conflicts for atf 0.9.

diffstat:

 external/bsd/atf/dist/atf-c/dynstr.c                         |   44 +-
 external/bsd/atf/dist/atf-c/fs.c                             |  104 +-
 external/bsd/atf/dist/atf-c/object.c                         |  108 -
 external/bsd/atf/dist/atf-c/object.h                         |   58 -
 external/bsd/atf/dist/atf-c/tc.c                             |   17 +-
 external/bsd/atf/dist/atf-compile/atf-compile.1              |   69 -
 external/bsd/atf/dist/atf-compile/atf-compile.cpp            |  160 --
 external/bsd/atf/dist/atf-compile/atf-host-compile.sh        |   88 -
 external/bsd/atf/dist/atf-run/atf-run.hooks                  |   94 -
 external/bsd/atf/dist/atf-sh/atf.footer.subr                 |  724 -----------
 external/bsd/atf/dist/atf-sh/atf.header.subr                 |   77 -
 external/bsd/atf/dist/atf-sh/atf.init.subr                   |   79 -
 external/bsd/atf/dist/atf-version/atf-version.cpp            |    3 +-
 external/bsd/atf/dist/data/atf-c++.pc.in                     |   11 -
 external/bsd/atf/dist/data/atf-c.pc.in                       |   11 -
 external/bsd/atf/dist/data/atf-run.hooks                     |   23 -
 external/bsd/atf/dist/data/tests-results.css                 |  160 --
 external/bsd/atf/dist/data/tests-results.dtd                 |   54 -
 external/bsd/atf/dist/data/tests-results.xsl                 |  421 ------
 external/bsd/atf/dist/doc/roadmap.xml                        |  270 ----
 external/bsd/atf/dist/doc/standalone/roadmap.html            |  447 ------
 external/bsd/atf/dist/doc/text/roadmap.txt                   |  193 --
 external/bsd/atf/dist/tests/atf/atf-c/d_include_object_h.c   |    1 -
 external/bsd/atf/dist/tests/atf/atf-compile/Atffile          |    5 -
 external/bsd/atf/dist/tests/atf/atf-compile/h_mode.cpp       |   53 -
 external/bsd/atf/dist/tests/atf/atf-compile/t_integration.sh |  125 -
 external/bsd/atf/dist/tests/atf/data/Atffile                 |    5 -
 external/bsd/atf/dist/tests/atf/data/t_pkg_config.sh         |  238 ---
 28 files changed, 101 insertions(+), 3541 deletions(-)

diffs (truncated from 4018 to 300 lines):

diff -r b9075f693983 -r a79a611669fb external/bsd/atf/dist/atf-c/dynstr.c
--- a/external/bsd/atf/dist/atf-c/dynstr.c      Fri Jun 04 08:23:34 2010 +0000
+++ b/external/bsd/atf/dist/atf-c/dynstr.c      Fri Jun 04 08:32:14 2010 +0000
@@ -1,7 +1,7 @@
 /*
  * Automated Testing Framework (atf)
  *
- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,7 @@
 
 #include <errno.h>
 #include <stdarg.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -121,22 +122,17 @@
 {
     atf_error_t err;
 
-    atf_object_init(&ad->m_object);
-
     ad->m_data = (char *)malloc(sizeof(char));
     if (ad->m_data == NULL) {
         err = atf_no_memory_error();
-        goto err_object;
+        goto out;
     }
 
     ad->m_data[0] = '\0';
     ad->m_datasize = 1;
     ad->m_length = 0;
     err = atf_no_error();
-    goto out;
 
-err_object:
-    atf_object_fini(&ad->m_object);
 out:
     return err;
 }
@@ -146,8 +142,6 @@
 {
     atf_error_t err;
 
-    atf_object_init(&ad->m_object);
-
     ad->m_datasize = strlen(fmt) + 1;
     ad->m_length = 0;
 
@@ -159,7 +153,7 @@
         ad->m_data = (char *)malloc(ad->m_datasize);
         if (ad->m_data == NULL) {
             err = atf_no_memory_error();
-            goto err_object;
+            goto out;
         }
 
         va_copy(ap2, ap);
@@ -168,7 +162,7 @@
         if (ret < 0) {
             free(ad->m_data);
             err = atf_libc_error(errno, "Cannot format string");
-            goto err_object;
+            goto out;
         }
 
         INV(ret >= 0);
@@ -180,10 +174,6 @@
     } while (ad->m_length >= ad->m_datasize);
 
     err = atf_no_error();
-    goto out;
-
-err_object:
-    atf_object_fini(&ad->m_object);
 out:
     POST(atf_is_error(err) || ad->m_data != NULL);
     return err;
@@ -207,17 +197,15 @@
 {
     atf_error_t err;
 
-    atf_object_init(&ad->m_object);
-
     if (memlen >= SIZE_MAX - 1) {
         err = atf_no_memory_error();
-        goto err_object;
+        goto out;
     }
 
     ad->m_data = (char *)malloc(memlen + 1);
     if (ad->m_data == NULL) {
         err = atf_no_memory_error();
-        goto err_object;
+        goto out;
     }
 
     ad->m_datasize = memlen + 1;
@@ -226,10 +214,7 @@
     ad->m_length = strlen(ad->m_data);
     INV(ad->m_length <= memlen);
     err = atf_no_error();
-    goto out;
 
-err_object:
-    atf_object_fini(&ad->m_object);
 out:
     return err;
 }
@@ -239,28 +224,23 @@
 {
     atf_error_t err;
 
-    atf_object_init(&ad->m_object);
-
     if (len == SIZE_MAX) {
         err = atf_no_memory_error();
-        goto err_object;
+        goto out;
     }
 
     ad->m_datasize = (len + 1) * sizeof(char);
     ad->m_data = (char *)malloc(ad->m_datasize);
     if (ad->m_data == NULL) {
         err = atf_no_memory_error();
-        goto err_object;
+        goto out;
     }
 
     memset(ad->m_data, ch, len);
     ad->m_data[len] = '\0';
     ad->m_length = len;
     err = atf_no_error();
-    goto out;
 
-err_object:
-    atf_object_fini(&ad->m_object);
 out:
     return err;
 }
@@ -283,8 +263,6 @@
 {
     atf_error_t err;
 
-    atf_object_copy(&dest->m_object, &src->m_object);
-
     dest->m_data = (char *)malloc(src->m_datasize);
     if (dest->m_data == NULL)
         err = atf_no_memory_error();
@@ -303,15 +281,11 @@
 {
     INV(ad->m_data != NULL);
     free(ad->m_data);
-
-    atf_object_fini(&ad->m_object);
 }
 
 char *
 atf_dynstr_fini_disown(atf_dynstr_t *ad)
 {
-    atf_object_fini(&ad->m_object);
-
     INV(ad->m_data != NULL);
     return ad->m_data;
 }
diff -r b9075f693983 -r a79a611669fb external/bsd/atf/dist/atf-c/fs.c
--- a/external/bsd/atf/dist/atf-c/fs.c  Fri Jun 04 08:23:34 2010 +0000
+++ b/external/bsd/atf/dist/atf-c/fs.c  Fri Jun 04 08:32:14 2010 +0000
@@ -1,7 +1,7 @@
 /*
  * Automated Testing Framework (atf)
  *
- * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -67,6 +67,7 @@
 static atf_error_t normalize(atf_dynstr_t *, char *);
 static atf_error_t normalize_ap(atf_dynstr_t *, const char *, va_list);
 static void replace_contents(atf_fs_path_t *, const char *);
+static atf_error_t set_immutable(const char *, bool, bool *);
 static const char *stat_type_to_string(const int);
 
 /* ---------------------------------------------------------------------
@@ -231,8 +232,13 @@
     atf_error_t err;
     struct dirent *de;
 
-    if (erase && !(atf_fs_stat_get_mode(st) & S_IWUSR)) {
-        if (chmod(pstr, atf_fs_stat_get_mode(st) | S_IWUSR) == -1) {
+    if (erase && ((atf_fs_stat_get_mode(st) & S_IRWXU) != S_IRWXU)) {
+        bool unused_done;
+        err = set_immutable(pstr, false, &unused_done);
+        if (atf_is_error(err))
+            goto out;
+
+        if (chmod(pstr, atf_fs_stat_get_mode(st) | S_IRWXU) == -1) {
             err = atf_libc_error(errno, "Cannot grant write permissions "
                                  "to %s", pstr);
             goto out;
@@ -465,6 +471,76 @@
 }
 
 static
+atf_error_t
+set_immutable(const char *filename, bool value, bool *done)
+{
+    atf_error_t err;
+
+#if HAVE_CHFLAGS
+    struct stat sb;
+
+    if (lstat(filename, &sb) == -1) {
+        err = atf_libc_error(errno, "lstat(%s) failed", filename);
+        goto out;
+    }
+
+    unsigned long new_flags = sb.st_flags;
+    if (value)
+        new_flags |= UF_IMMUTABLE;
+    else
+        new_flags &= ~UF_IMMUTABLE;
+
+    if (chflags(filename, new_flags) == -1) {
+        err = atf_libc_error(errno, "chflags(%s) failed", filename);
+        goto out;
+    }
+
+    err = atf_no_error();
+    *done = true;
+
+out:
+#elif HAVE_CHATTR
+    if (atf_user_is_root()) {
+        /* TODO: This should use ioctl(2) instead of chattr(1), but it looks
+         * like that the API to set the immutable value is file-system specific.
+         * Investigate this later. */
+        atf_fs_path_t prog;
+
+        err = atf_fs_path_init_fmt(&prog, CHATTR);
+        if (!atf_is_error(err)) {
+            atf_process_status_t status;
+            const char *argv[4] = { "chattr", value ? "+i" : "-i", filename,
+                                    NULL };
+
+            err = atf_process_exec_array(&status, &prog, argv, NULL, NULL);
+            if (!atf_is_error(err)) {
+                if (!atf_process_status_exited(&status) ||
+                    atf_process_status_exitstatus(&status) != EXIT_SUCCESS) {
+                    /* XXX: This is the wrong error type. */
+                    err = atf_libc_error(EINVAL, "Failed to exec chattr");
+                }
+
+                atf_process_status_fini(&status);
+            }
+
+            atf_fs_path_fini(&prog);
+        }
+        *done = true;
+    } else {
+        /* Linux doesn't allow to set the immutability bit by non-root; just
+         * report it as an unsupported case. */
+        err = atf_no_error();
+        *done = false;
+    }
+#else
+    err = atf_no_error();
+    *done = false;
+#endif
+
+    return err;
+}
+
+static
 const char *
 stat_type_to_string(const int type)
 {
@@ -508,8 +584,6 @@
     atf_error_t err;
     va_list ap2;
 
-    atf_object_init(&p->m_object);
-
     va_copy(ap2, ap);
     err = normalize_ap(&p->m_data, fmt, ap2);
     va_end(ap2);
@@ -533,8 +607,6 @@
 atf_error_t
 atf_fs_path_copy(atf_fs_path_t *dest, const atf_fs_path_t *src)
 {
-    atf_object_copy(&dest->m_object, &src->m_object);
-
     return atf_dynstr_copy(&dest->m_data, &src->m_data);
 }
 



Home | Main Index | Thread Index | Old Index