1#!/bin/sh 2# 3# aegis - The "aegis" program. 4# Copyright (C) 2008, 2010 Walter Franzini 5# Copyright (C) 2012 Peter Miller 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 3 of the License, or (at 10# your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15# General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License along 18# with this program. If not, see <http://www.gnu.org/licenses/>. 19# 20 21TEST_SUBJECT="aediff vs. mismatching UUIDs" 22 23# load up standard prelude and test functions 24. test_funcs 25 26check_it() 27{ 28 sed -e "s|$work|...|g" \ 29 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 30 -e "s/\"$USER\"/\"USER\"/g" \ 31 -e 's/19[0-9][0-9]/YYYY/' \ 32 -e 's/20[0-9][0-9]/YYYY/' \ 33 -e 's/node = ".*"/node = "NODE"/' \ 34 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 35 < $2 > $work/sed.out 36 if test $? -ne 0; then no_result; fi 37 diff -b $1 $work/sed.out 38 if test $? -ne 0; then fail; fi 39} 40 41# 42# make a new project 43# 44activity="new project 44" 45aegis -newpro foo -version "" -dir $work/proj -lib $work/lib 46if test $? -ne 0 ; then fail; fi 47 48AEGIS_PROJECT=foo 49export AEGIS_PROJECT 50 51# 52# change project attributes 53# 54activity="project attributes 54" 55cat > atts << 'fubar' 56description = "The \"foo\" program."; 57developer_may_review = true; 58developer_may_integrate = true; 59reviewer_may_integrate = true; 60developers_may_create_changes = true; 61umask = 022; 62default_test_exemption = true; 63default_test_regression_exemption = true; 64minimum_change_number = 10; 65reuse_change_numbers = true; 66minimum_branch_number = 1; 67skip_unlucky = false; 68compress_database = false; 69develop_end_action = goto_awaiting_integration; 70protect_development_directory = false; 71fubar 72test $? -eq 0 || no_result 73 74aegis -proatt -f atts -proj foo -lib $work/lib 75test $? -eq 0 || no_result 76 77activity="new developer 77" 78aegis -newdev $USER 79test $? -eq 0 || no_result 80aegis -new-reviewer $USER 81test $? -eq 0 || no_result 82aegis -new-integrator $USER 83test $? -eq 0 || no_result 84 85# 86# create a new change 87# 88activity="new change 88" 89cat > cattr << 'end' 90brief_description = "First change."; 91cause = internal_enhancement; 92end 93test $? -eq 0 || no_result 94aegis -new_change 1 -f cattr -project $AEGIS_PROJECT 95test $? -eq 0 || no_result 96 97activity="develop begin 97" 98aegis -dev-begin 1 -dir $work/dd 99test $? -eq 0 || no_result 100 101# 102# add a new files to the change 103# 104activity="new file 104" 105aegis -new-file $work/dd/aegis.conf 106test $? -eq 0 || no_result 107 108cat > $work/dd/aegis.conf << 'fubar' 109build_command = "exit 0"; 110diff_command = 111 "set +e;" 112 "diff -a ${quote $original} ${quote $input}" 113 " > ${quote $output};" 114 "test $? -le 1"; 115merge_command = "set +e; " 116 "merge -p -L baseline -L Historical -L C$c " 117 "${quote $mostrecent} ${quote $original} ${quote $input} " 118 "> ${quote $output}; " 119 "test $? -le 1"; 120history_get_command = "aesvt -check-out -edit ${quote $edit} " 121 "-history ${quote $history} -f ${quote $output}"; 122history_put_command = "aesvt -check-in -history ${quote $history} " 123 "-f ${quote $input}"; 124history_query_command = "aesvt -query -history ${quote $history}"; 125history_content_limitation = binary_capable; 126fubar 127test $? -eq 0 || no_result 128 129 130# 131# finish development of the change 132# 133activity="finish dev 133" 134aefinish 1 > LOG 2>&1 135if test $? -ne 0; then cat LOG; no_result; fi 136 137# 138# integrate the change 139# 140activity="finis int 140" 141aefinish 1 > LOG 2>&1 142if test $? -ne 0; then cat LOG; no_result; fi 143 144# -------------------------------------------------------------------------- 145 146# 147# we create a branch, because the bug is about branches 148# 149aegis -p foo -nbr 2 -v > LOG 2>&1 150if test $? -ne 0; then cat LOG; no_result; fi 151 152AEGIS_PROJECT=foo.2 153export AEGIS_PROJECT 154 155# 156# create a new change 157# 158activity="new change 158" 159cat > cattr << 'end' 160brief_description = "First change."; 161cause = internal_enhancement; 162end 163test $? -eq 0 || no_result 164aegis -new_change 1 -f cattr -project $AEGIS_PROJECT 165test $? -eq 0 || no_result 166 167activity="develop begin 167" 168aegis -dev-begin 1 -dir $work/dd 169test $? -eq 0 || no_result 170 171# 172# add a new files to the change 173# 174activity="new file 174" 175aegis -new-file $work/dd/barney \ 176 -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1 177test $? -eq 0 || no_result 178 179cat > $work/dd/barney <<EOF 180Hi, I'm Barney! 181EOF 182test $? -eq 0 || no_result 183 184activity="set change uuid 184" 185aegis -change-attr 1 -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddffff \ 186 > LOG 2>&1 187test $? -eq 0 || no_result 188 189activity="finish the change 189" 190aefinish 1 > LOG 2>&1 191if test $? -ne 0; then cat LOG; no_result; fi 192 193aefinish 1 > LOG 2>&1 194if test $? -ne 0; then cat LOG; no_result; fi 195 196activity="check fstate 196" 197cat > ok <<EOF 198src = 199[ 200 { 201 file_name = "barney"; 202 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1"; 203 action = create; 204 edit = 205 { 206 revision = "1"; 207 encoding = none; 208 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddffff"; 209 }; 210 edit_origin = 211 { 212 revision = "1"; 213 encoding = none; 214 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddffff"; 215 }; 216 usage = source; 217 file_fp = 218 { 219 youngest = TIME; 220 oldest = TIME; 221 crypto = "GUNK"; 222 }; 223 diff_file_fp = 224 { 225 youngest = TIME; 226 oldest = TIME; 227 crypto = "GUNK"; 228 }; 229 }, 230]; 231EOF 232test $? -eq 0 || no_result 233 234check_it ok $work/proj/info/change/0/002.fs 235 236# -------------------------------------------------------------------------- 237# 238# The second branch 239# 240# --------------------------------------------------------------------------00 241aegis -p foo -nbr 3 -v > LOG 2>&1 242if test $? -ne 0; then cat LOG; no_result; fi 243 244AEGIS_PROJECT=foo.3 245export AEGIS_PROJECT 246 247# 248# create a new change 249# 250activity="new change 250" 251cat > cattr << 'end' 252brief_description = "First change."; 253cause = internal_enhancement; 254end 255test $? -eq 0 || no_result 256aegis -new_change 1 -f cattr -project $AEGIS_PROJECT 257test $? -eq 0 || no_result 258 259activity="develop begin 259" 260aegis -dev-begin 1 -dir $work/dd 261test $? -eq 0 || no_result 262 263# 264# add a new files to the change 265# 266activity="new file 266" 267aegis -new-file $work/dd/barney 268test $? -eq 0 || no_result 269 270activity="check fstate 270" 271cat > ok <<EOF 272src = 273[ 274 { 275 file_name = "barney"; 276 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1"; 277 action = create; 278 usage = source; 279 }, 280]; 281EOF 282test $? -eq 0 || no_result 283 284check_it ok $work/proj/info/change/0/003.branch/0/001.fs 285 286# 287# We explicitly set the file's UUID to be sure that fixing aeipass 288# does not make this test useless. We want the UUIDs to be different! 289# 290# We need to do it manually since the new code make it impossible this 291# to happen. Or at least really difficult to make it happen. 292# 293cat > $work/proj/info/change/0/003.branch/0/001.fs <<EOF 294src = 295[ 296 { 297 file_name = "barney"; 298 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd2"; 299 action = create; 300 usage = source; 301 edit = 302 { 303 revision = "1"; 304 encoding = none; 305 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddfffe"; 306 }; 307 edit_origin = 308 { 309 revision = "1"; 310 encoding = none; 311 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddfffe"; 312 }; 313 }, 314]; 315EOF 316 317cat > $work/dd/barney <<EOF 318Hi, I'm not Barney! 319EOF 320test $? -eq 0 || no_result 321 322activity="set change uuid 322" 323aegis -change-attr 1 -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddfffe 324test $? -eq 0 || no_result 325 326activity="develop and the change 326" 327aefinish 1 > LOG 2>&1 328if test $? -ne 0; then cat LOG; no_result; fi 329 330aefinish 1 > LOG 2>&1 331if test $? -ne 0; then cat LOG; no_result; fi 332 333activity="check fstate 333" 334cat > ok <<EOF 335src = 336[ 337 { 338 file_name = "barney"; 339 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd2"; 340 action = create; 341 edit = 342 { 343 revision = "1"; 344 encoding = none; 345 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddfffe"; 346 }; 347 edit_origin = 348 { 349 revision = "1"; 350 encoding = none; 351 uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddfffe"; 352 }; 353 usage = source; 354 file_fp = 355 { 356 youngest = TIME; 357 oldest = TIME; 358 crypto = "GUNK"; 359 }; 360 diff_file_fp = 361 { 362 youngest = TIME; 363 oldest = TIME; 364 crypto = "GUNK"; 365 }; 366 }, 367]; 368EOF 369test $? -eq 0 || no_result 370 371check_it ok $work/proj/info/change/0/003.fs 372 373# 374# diff the files 375# 376activity="run aediff 376" 377cat > ok <<EOF 378*** 2.D001/barney 379--- 3.D001/barney 380*************** 381*** 1 **** 382! Hi, I'm Barney! 383--- 1 ---- 384! Hi, I'm not Barney! 385EOF 386test $? -eq 0 || no_result 387 388aediff -context -c 2.d1 -c 3.d1 barney > test.out 389if test $? -ne 0; then no_result; fi 390 391diff -c ok test.out 392if test $? -ne 0; then fail; fi 393 394# 395# Only definite negatives are possible. 396# The functionality exercised by this test appears to work, 397# no other guarantees are made. 398# 399pass 400# vim: set ts=8 sw=4 et : 401