netatalk  4.6.1
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
test_migrate.c File Reference
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "../../bin/afppasswd/afppasswd_migrate.c"

Data Structures

struct  test_context
 

Macros

#define getpwnam   test_getpwnam
 
#define write   test_write
 
#define fsync   test_sync
 
#define mkdirat   test_mkdirat
 
#define unlinkat   test_unlinkat
 
#define SALT_HEX_LEN   32
 
#define VERIFIER_HEX_LEN   384
 

Functions

static struct passwd * test_getpwnam (const char *name)
 
static ssize_t test_write (int fd, const void *data, size_t length)
 
static int test_sync (int fd)
 
static int test_mkdirat (int fd, const char *path, mode_t mode)
 
static int test_unlinkat (int fd, const char *path, int flags)
 
const char * tmpdir (void)
 Find a suitable temporary directory for Netatalk.
 
static void report (int passed, const char *name)
 
static char * make_record (const char *username, char salt, char verifier)
 
static int write_file (const char *path, const char *data)
 
static char * read_file (const char *path)
 
static int make_case (char directory[MAXPATHLEN+1], char path[MAXPATHLEN+1], const char *source)
 
static void remove_case (const char *directory)
 
static int count_case_entries (const char *directory)
 
static int run_migration (const char *path, struct test_context *context)
 
static int source_is_unchanged (const char *path, const char *expected)
 
static void test_success (mode_t mode, const char *description)
 
static void test_final_record_without_newline (void)
 
static void test_rejected_source (const char *name, const char *source, int collide_uids)
 
static void test_disabled_ownership (void)
 
static void test_write_failure (void)
 
static void test_sync_failure (int sync_call, const char *name)
 
static void test_rollback_cleanup_failure (int sync_call, int fail_unlink, const char *name)
 
static void test_backup_collision_and_repeat (void)
 
static void test_unsafe_metadata (void)
 
static void test_hardlinked_source (void)
 
static void test_staging_collision (void)
 
static void test_partial_destination (void)
 
int main (void)
 

Variables

static struct test_context * active_context
 
static int tests_run
 
static int tests_failed
 

Macro Definition Documentation

◆ fsync

#define fsync   test_sync

◆ getpwnam

#define getpwnam   test_getpwnam

◆ mkdirat

#define mkdirat   test_mkdirat

◆ SALT_HEX_LEN

#define SALT_HEX_LEN   32

◆ unlinkat

#define unlinkat   test_unlinkat

◆ VERIFIER_HEX_LEN

#define VERIFIER_HEX_LEN   384

◆ write

#define write   test_write

Function Documentation

◆ count_case_entries()

static int count_case_entries ( const char *  directory)
static

◆ main()

int main ( void  )

◆ make_case()

static int make_case ( char  directory[MAXPATHLEN+1],
char  path[MAXPATHLEN+1],
const char *  source 
)
static

◆ make_record()

static char * make_record ( const char *  username,
char  salt,
char  verifier 
)
static

◆ read_file()

static char * read_file ( const char *  path)
static

◆ remove_case()

static void remove_case ( const char *  directory)
static

◆ report()

static void report ( int  passed,
const char *  name 
)
static

◆ run_migration()

static int run_migration ( const char *  path,
struct test_context *  context 
)
static

◆ source_is_unchanged()

static int source_is_unchanged ( const char *  path,
const char *  expected 
)
static

◆ test_backup_collision_and_repeat()

static void test_backup_collision_and_repeat ( void  )
static

◆ test_disabled_ownership()

static void test_disabled_ownership ( void  )
static

◆ test_final_record_without_newline()

static void test_final_record_without_newline ( void  )
static

◆ test_getpwnam()

static struct passwd * test_getpwnam ( const char *  name)
static

◆ test_hardlinked_source()

static void test_hardlinked_source ( void  )
static

◆ test_mkdirat()

static int test_mkdirat ( int  fd,
const char *  path,
mode_t  mode 
)
static

◆ test_partial_destination()

static void test_partial_destination ( void  )
static

◆ test_rejected_source()

static void test_rejected_source ( const char *  name,
const char *  source,
int  collide_uids 
)
static

◆ test_rollback_cleanup_failure()

static void test_rollback_cleanup_failure ( int  sync_call,
int  fail_unlink,
const char *  name 
)
static

◆ test_staging_collision()

static void test_staging_collision ( void  )
static

◆ test_success()

static void test_success ( mode_t  mode,
const char *  description 
)
static

◆ test_sync()

static int test_sync ( int  fd)
static

◆ test_sync_failure()

static void test_sync_failure ( int  sync_call,
const char *  name 
)
static

◆ test_unlinkat()

static int test_unlinkat ( int  fd,
const char *  path,
int  flags 
)
static

◆ test_unsafe_metadata()

static void test_unsafe_metadata ( void  )
static

◆ test_write()

static ssize_t test_write ( int  fd,
const void *  data,
size_t  length 
)
static

◆ test_write_failure()

static void test_write_failure ( void  )
static

◆ tmpdir()

const char * tmpdir ( void  )
extern

Find a suitable temporary directory for Netatalk.

Creates a subdirectory for current gid if it doesn't exist. The result should be copied immediately as it may be overwritten by a subsequent call.

◆ write_file()

static int write_file ( const char *  path,
const char *  data 
)
static

Variable Documentation

◆ active_context

struct test_context* active_context
static

◆ tests_failed

int tests_failed
static

◆ tests_run

int tests_run
static