From 39022119b2ffa04ff8bac4667cc4af7e80929a54 Mon Sep 17 00:00:00 2001 From: Diego Ongaro Date: Tue, 18 Aug 2020 16:52:20 -0700 Subject: [PATCH 3/3] find: Add test for sort --- tests/find/sorted.sh | 80 ++++++++++++++++++++++++++++++++++++++++++++ tests/local.mk | 1 + 2 files changed, 81 insertions(+) create mode 100644 tests/find/sorted.sh diff --git a/tests/find/sorted.sh b/tests/find/sorted.sh new file mode 100644 index 00000000..5a1b5fa5 --- /dev/null +++ b/tests/find/sorted.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Verify that find -s sorts the paths by name. + +# Copyright (C) 2020 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; fu_path_prepend_ +print_ver_ find + +touch 6253 0812 2790 6311 1958 0211 8704 4019 5408 1001 8501 +mkdir 6331 1239 8506 0496 3663 4040 0327 5338 2465 2749 7012 +touch 6331.{7271,9632,3176,7771,2154} +touch 6331/{5562,4722,7458,5517,2390} +mkdir 6331.{9616,3834,4639,2832,0804} +mkdir 6331/{5961,1694,2227,0628,1041} + +find -s > sorted + +cat <<_EOD_ > expout || framework_failure_ +. +./0211 +./0327 +./0496 +./0812 +./1001 +./1239 +./1958 +./2465 +./2749 +./2790 +./3663 +./4019 +./4040 +./5338 +./5408 +./6253 +./6311 +./6331 +./6331/0628 +./6331/1041 +./6331/1694 +./6331/2227 +./6331/2390 +./6331/4722 +./6331/5517 +./6331/5562 +./6331/5961 +./6331/7458 +./6331.0804 +./6331.2154 +./6331.2832 +./6331.3176 +./6331.3834 +./6331.4639 +./6331.7271 +./6331.7771 +./6331.9616 +./6331.9632 +./7012 +./8501 +./8506 +./8704 +./sorted +_EOD_ + +compare expout sorted || fail=1 + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk index 13782d86..0d87d099 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -117,6 +117,7 @@ all_tests = \ tests/find/refuse-noop.sh \ tests/find/debug-missing-arg.sh \ tests/find/used.sh \ + tests/find/sorted.sh \ tests/xargs/verbose-quote.sh \ $(all_root_tests) -- 2.27.0