netatalk  4.6.0
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_contextactive_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()

int count_case_entries ( const char * directory)
static

◆ main()

int main ( void )

◆ make_case()

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

◆ make_record()

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

◆ read_file()

char * read_file ( const char * path)
static

◆ remove_case()

void remove_case ( const char * directory)
static

◆ report()

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

◆ run_migration()

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

◆ source_is_unchanged()

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

◆ test_backup_collision_and_repeat()

void test_backup_collision_and_repeat ( void )
static

◆ test_disabled_ownership()

void test_disabled_ownership ( void )
static

◆ test_final_record_without_newline()

void test_final_record_without_newline ( void )
static

◆ test_getpwnam()

struct passwd * test_getpwnam ( const char * name)
static

◆ test_hardlinked_source()

void test_hardlinked_source ( void )
static

◆ test_mkdirat()

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

◆ test_partial_destination()

void test_partial_destination ( void )
static

◆ test_rejected_source()

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

◆ test_rollback_cleanup_failure()

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

◆ test_staging_collision()

void test_staging_collision ( void )
static

◆ test_success()

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

◆ test_sync()

int test_sync ( int fd)
static

◆ test_sync_failure()

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

◆ test_unlinkat()

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

◆ test_unsafe_metadata()

void test_unsafe_metadata ( void )
static

◆ test_write()

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

◆ test_write_failure()

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()

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