106 lines
2.5 KiB
C
106 lines
2.5 KiB
C
#include <library/omni.h>
|
|
#include <public/zParams.h>
|
|
|
|
typedef struct NamedBeast_s NamedBeast_s;
|
|
#include <include/lsa.h>
|
|
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
#define CHECK(expr) \
|
|
do { \
|
|
if (!(expr)) { \
|
|
fprintf(stderr, "CHECK failed at %s:%d: %s\n", __FILE__, __LINE__, #expr); \
|
|
return 1; \
|
|
} \
|
|
} while (0)
|
|
|
|
static int dentry_calls;
|
|
static int vol_calls;
|
|
static int noatime_calls;
|
|
static VolumeID_t *last_volume;
|
|
static BOOL last_noatime;
|
|
static Zid_t last_inode_zid;
|
|
|
|
static void test_invalidate_dentry(LSAInvalidateDentry_s *lsa_inv)
|
|
{
|
|
dentry_calls++;
|
|
last_volume = &lsa_inv->lid_volID;
|
|
}
|
|
|
|
static void test_invalidate_vol(VolumeID_t *vol_id)
|
|
{
|
|
vol_calls++;
|
|
last_volume = vol_id;
|
|
}
|
|
|
|
static void test_noatime(VolumeID_t *vol_id, BOOL on)
|
|
{
|
|
noatime_calls++;
|
|
last_volume = vol_id;
|
|
last_noatime = on;
|
|
}
|
|
|
|
static NINT test_get_vol_namespace(VolumeID_t *vol_id)
|
|
{
|
|
last_volume = vol_id;
|
|
return 17;
|
|
}
|
|
|
|
static struct inode *test_get_inode(VolumeID_t *vol_id, Zid_t zid)
|
|
{
|
|
last_volume = vol_id;
|
|
last_inode_zid = zid;
|
|
return (struct inode *)(uintptr_t)0x1234U;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
LSAInvalidateDentry_s lsa_inv;
|
|
VolumeID_t volume;
|
|
struct inode *inode;
|
|
|
|
CHECK(Ptr_lsa_invalidate_dentry == NULL);
|
|
CHECK(Ptr_lsa_invalidate_vol == NULL);
|
|
CHECK(Ptr_lsa_noatime == NULL);
|
|
CHECK(Ptr_lsa_get_vol_namespace == NULL);
|
|
CHECK(Ptr_lsa_get_inode == NULL);
|
|
|
|
Ptr_lsa_invalidate_dentry = test_invalidate_dentry;
|
|
Ptr_lsa_invalidate_vol = test_invalidate_vol;
|
|
Ptr_lsa_noatime = test_noatime;
|
|
Ptr_lsa_get_vol_namespace = test_get_vol_namespace;
|
|
Ptr_lsa_get_inode = test_get_inode;
|
|
|
|
lsa_inv.lid_zid = 0x55;
|
|
lsa_inv.lid_pZid = 0x44;
|
|
Ptr_lsa_invalidate_dentry(&lsa_inv);
|
|
CHECK(dentry_calls == 1);
|
|
CHECK(last_volume == &lsa_inv.lid_volID);
|
|
|
|
Ptr_lsa_invalidate_vol(&volume);
|
|
CHECK(vol_calls == 1);
|
|
CHECK(last_volume == &volume);
|
|
|
|
Ptr_lsa_noatime(&volume, TRUE);
|
|
CHECK(noatime_calls == 1);
|
|
CHECK(last_volume == &volume);
|
|
CHECK(last_noatime == TRUE);
|
|
|
|
CHECK(Ptr_lsa_get_vol_namespace(&volume) == 17);
|
|
CHECK(last_volume == &volume);
|
|
|
|
inode = Ptr_lsa_get_inode(&volume, (Zid_t)0x7788);
|
|
CHECK(inode == (struct inode *)(uintptr_t)0x1234U);
|
|
CHECK(last_volume == &volume);
|
|
CHECK(last_inode_zid == (Zid_t)0x7788);
|
|
|
|
Ptr_lsa_invalidate_dentry = NULL;
|
|
Ptr_lsa_invalidate_vol = NULL;
|
|
Ptr_lsa_noatime = NULL;
|
|
Ptr_lsa_get_vol_namespace = NULL;
|
|
Ptr_lsa_get_inode = NULL;
|
|
|
|
return 0;
|
|
}
|