New upstream version 2017.13
This commit is contained in:
commit
8f7f43a65b
174 files changed
+5474
-2244
No files matched your search
@@ -32,8 +32,8 @@ static gboolean
|
||||
renameat_test_setup (int *out_srcfd, int *out_destfd,
|
||||
GError **error)
|
||||
{
|
||||
glnx_fd_close int srcfd = -1;
|
||||
glnx_fd_close int destfd = -1;
|
||||
glnx_autofd int srcfd = -1;
|
||||
glnx_autofd int destfd = -1;
|
||||
|
||||
(void) glnx_shutil_rm_rf_at (AT_FDCWD, "srcdir", NULL, NULL);
|
||||
if (mkdir ("srcdir", 0755) < 0)
|
||||
@@ -62,8 +62,8 @@ static void
|
||||
test_renameat2_noreplace (void)
|
||||
{
|
||||
_GLNX_TEST_DECLARE_ERROR(local_error, error);
|
||||
glnx_fd_close int srcfd = -1;
|
||||
glnx_fd_close int destfd = -1;
|
||||
glnx_autofd int srcfd = -1;
|
||||
glnx_autofd int destfd = -1;
|
||||
struct stat stbuf;
|
||||
|
||||
if (!renameat_test_setup (&srcfd, &destfd, error))
|
||||
@@ -92,8 +92,8 @@ test_renameat2_exchange (void)
|
||||
{
|
||||
_GLNX_TEST_DECLARE_ERROR(local_error, error);
|
||||
|
||||
glnx_fd_close int srcfd = -1;
|
||||
glnx_fd_close int destfd = -1;
|
||||
glnx_autofd int srcfd = -1;
|
||||
glnx_autofd int destfd = -1;
|
||||
if (!renameat_test_setup (&srcfd, &destfd, error))
|
||||
return;
|
||||
|
||||
@@ -161,13 +161,22 @@ test_fstatat (void)
|
||||
return;
|
||||
g_assert_cmpint (errno, ==, ENOENT);
|
||||
g_assert_no_error (local_error);
|
||||
|
||||
/* test NULL parameter for stat */
|
||||
if (!glnx_fstatat_allow_noent (AT_FDCWD, ".", NULL, 0, error))
|
||||
return;
|
||||
g_assert_cmpint (errno, ==, 0);
|
||||
g_assert_no_error (local_error);
|
||||
if (!glnx_fstatat_allow_noent (AT_FDCWD, "nosuchfile", NULL, 0, error))
|
||||
return;
|
||||
g_assert_cmpint (errno, ==, ENOENT);
|
||||
g_assert_no_error (local_error);
|
||||
}
|
||||
|
||||
static void
|
||||
test_filecopy (void)
|
||||
{
|
||||
_GLNX_TEST_DECLARE_ERROR(local_error, error);
|
||||
g_auto(GLnxTmpfile) tmpf = { 0, };
|
||||
const char foo[] = "foo";
|
||||
struct stat stbuf;
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
*
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "libglnx.h"
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <gio/gio.h>
|
||||
#include <err.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libglnx-testlib.h"
|
||||
|
||||
static void
|
||||
test_mkdir_p_enoent (void)
|
||||
{
|
||||
_GLNX_TEST_DECLARE_ERROR(local_error, error);
|
||||
glnx_autofd int dfd = -1;
|
||||
|
||||
if (!glnx_ensure_dir (AT_FDCWD, "test", 0755, error))
|
||||
return;
|
||||
if (!glnx_opendirat (AT_FDCWD, "test", FALSE, &dfd, error))
|
||||
return;
|
||||
if (rmdir ("test") < 0)
|
||||
return (void) glnx_throw_errno_prefix (error, "rmdir(%s)", "test");
|
||||
|
||||
/* This should fail with ENOENT. */
|
||||
glnx_shutil_mkdir_p_at (dfd, "blah/baz", 0755, NULL, error);
|
||||
g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
|
||||
g_clear_error (&local_error);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/mkdir-p/enoent", test_mkdir_p_enoent);
|
||||
|
||||
ret = g_test_run();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ do_write_run (GLnxDirFdIterator *dfd_iter, GError **error)
|
||||
{
|
||||
guint32 randname_v = g_random_int ();
|
||||
g_autofree char *randname = g_strdup_printf ("file%u", randname_v);
|
||||
glnx_fd_close int fd = -1;
|
||||
glnx_autofd int fd = -1;
|
||||
|
||||
again:
|
||||
fd = openat (dfd_iter->fd, randname, O_CREAT | O_EXCL, 0644);
|
||||
@@ -113,7 +113,7 @@ do_write_run (GLnxDirFdIterator *dfd_iter, GError **error)
|
||||
if (!dent)
|
||||
break;
|
||||
|
||||
glnx_fd_close int fd = -1;
|
||||
glnx_autofd int fd = -1;
|
||||
if (!glnx_openat_rdonly (dfd_iter->fd, dent->d_name, FALSE, &fd, error))
|
||||
return FALSE;
|
||||
|
||||
@@ -157,7 +157,7 @@ do_read_run (GLnxDirFdIterator *dfd_iter,
|
||||
if (!dent)
|
||||
break;
|
||||
|
||||
glnx_fd_close int fd = -1;
|
||||
glnx_autofd int fd = -1;
|
||||
if (!glnx_openat_rdonly (dfd_iter->fd, dent->d_name, FALSE, &fd, error))
|
||||
return FALSE;
|
||||
|
||||
|
||||
Reference in new issue
Block a user