/* This function coordinates the test for each filesystem type. */
static void
test_filesystem (guestfs_h *g, const struct filesystem *fs)
{
  if (fs->fs_feature && !feature_available (g, fs->fs_feature)) {
    printf ("skipped test of %s because %s feature not available\n",
            fs->fs_name, fs->fs_feature);
    return;
  }

  printf ("testing charset fidelity on %s\n", fs->fs_name);

  make_filesystem (g, fs);
  mount_filesystem (g, fs);

  test_ascii (g, fs);

  if (fs->fs_8bit_only)
    goto out;

  if (!fs->fs_skip_latin1)
    test_latin1 (g, fs);
  if (!fs->fs_skip_latin2)
    test_latin2 (g, fs);
  test_chinese (g, fs);

 out:
  unmount_filesystem (g, fs);
}
/* This function coordinates the test for each filesystem type. */
static void
test_filesystem (guestfs_h *g, const struct filesystem *fs)
{
  const char *feature[] = { fs->fs_feature, NULL };
  char envvar[sizeof (ourenvvar) + 20];
  char *str;

  if (fs->fs_feature && !guestfs_feature_available (g, (char **) feature)) {
    printf ("skipped test of %s because %s feature not available\n",
            fs->fs_name, fs->fs_feature);
    return;
  }

  snprintf (envvar, sizeof envvar, "%s_%s", ourenvvar, fs->fs_name);
  str = getenv (envvar);
  if (str && STREQ (str, "1")) {
    printf ("skipped test of %s because environment variable is set\n",
            fs->fs_name);
    return;
  }

  printf ("testing charset fidelity on %s\n", fs->fs_name);

  make_filesystem (g, fs);
  mount_filesystem (g, fs);

  test_ascii (g, fs);

  if (fs->fs_8bit_only)
    goto out;

  if (!fs->fs_skip_latin1)
    test_latin1 (g, fs);
  if (!fs->fs_skip_latin2)
    test_latin2 (g, fs);
  test_chinese (g, fs);

 out:
  unmount_filesystem (g, fs);
}