Home | History | Annotate | Download | only in filesystems
      1 // Copyright 2014 The Android Open Source Project
      2 //
      3 // This software is licensed under the terms of the GNU General Public
      4 // License version 2, as published by the Free Software Foundation, and
      5 // may be copied, distributed, and modified under those terms.
      6 //
      7 // This program is distributed in the hope that it will be useful,
      8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
      9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     10 // GNU General Public License for more details.
     11 
     12 #include "android/filesystems/fstab_parser.h"
     13 
     14 #include <gtest/gtest.h>
     15 
     16 TEST(FstabParser, ParsePartitionFormat) {
     17     static const char kFstab[] =
     18         "# Android fstab file.\n"
     19         "#<src>                                                  <mnt_point>         <type>    <mnt_flags and options>                              <fs_mgr_flags>\n"
     20         "# The filesystem that contains the filesystem checker binary (typically /system) cannot\n"
     21         "# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK\n"
     22         "/dev/block/mtdblock0                                    /system             ext4      ro,barrier=1                                         wait\n"
     23         "/dev/block/mtdblock1\t      \t                          /data\t             yaffs2    noatime,nosuid,nodev,barrier=1,nomblk_io_submit      wait,check\n"
     24         "/dev/block/mtdblock2\t/cache\tntfs\tnoatime,nosuid,nodev  wait,check\n"
     25         "/devices/platform/goldfish_mmc.0\t\t\tauto\tvfat      defaults                                             voldmanaged=sdcard:auto\n"
     26         ;
     27     static const size_t kFstabSize = sizeof(kFstab);
     28 
     29     char* out = NULL;
     30     EXPECT_TRUE(android_parseFstabPartitionFormat(kFstab, kFstabSize,
     31                                                   "/system", &out));
     32     EXPECT_STREQ("ext4", out);
     33     free(out);
     34 
     35     EXPECT_TRUE(android_parseFstabPartitionFormat(kFstab, kFstabSize,
     36                                                   "/data", &out));
     37     EXPECT_STREQ("yaffs2", out);
     38     free(out);
     39 
     40     EXPECT_TRUE(android_parseFstabPartitionFormat(kFstab, kFstabSize,
     41                                                   "/cache", &out));
     42     EXPECT_STREQ("ntfs", out);
     43     free(out);
     44 
     45     EXPECT_FALSE(android_parseFstabPartitionFormat(kFstab, kFstabSize,
     46                                                    "/unknown", &out));
     47 }
     48