1#!/bin/zsh 2#************************************************************** 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the 9# "License"); you may not use this file except in compliance 10# with the License. You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, 15# software distributed under the License is distributed on an 16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17# KIND, either express or implied. See the License for the 18# specific language governing permissions and limitations 19# under the License. 20# 21#************************************************************** 22# usage: drive.sh <ext|strict|v00|v10|v11|v13|x13> <port> <jobs.tsv> <done.tsv> (DefaultVersion 3, 4, 0 UNKNOWN, 1 = ODF 1.0, 2 = ODF 1.1, 5 = ODF 1.3, 6 = ODF 1.3 Extended) 23# No mode name may be a prefix of another: the kills below match "profile_<mode>" as a pattern (a mode ext13 died when ext finished). 24# Converts jobs in batches of 20. Stops on the first soffice crash; kills and resumes on a hang. 25source ${0:A:h}/env.sh 26mode=$1; port=$2; jobs=$3; done_=$4; log=${done_:r}.log 27prof=$mode 28if [[ ! -e $D/runs/profile_$prof/user/registrymodifications.xcu ]]; then 29 mkdir -p $D/runs/profile_$prof/user 30 case $mode in v00) v=0;; v10) v=1;; v11) v=2;; ext) v=3;; strict) v=4;; v13) v=5;; x13) v=6;; *) echo "drive.sh: unknown mode $mode" >&2; exit 2;; esac 31 cat > $D/runs/profile_$prof/user/registrymodifications.xcu <<XCU 32<?xml version="1.0" encoding="UTF-8"?> 33<oor:items xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 34<item oor:path="/org.openoffice.Office.Common/Save/ODF"><prop oor:name="DefaultVersion" oor:op="fuse"><value>$v</value></prop></item> 35</oor:items> 36XCU 37fi 38total=$(wc -l < $jobs) 39(( total > 0 )) || { echo "drive.sh: no jobs in $jobs" >&2; exit 2; } 40while true; do 41 started=$(cut -f1 $done_ 2>/dev/null | sort -u | wc -l) 42 (( started >= total )) && break 43 lsof -nP -iTCP:$port -sTCP:LISTEN >/dev/null 2>&1 || $D/start.sh $prof $port || exit 2 44 gtimeout 300 $D/runpy.sh $D/convert.py $port $jobs $done_ 20 >> $log 2>&1 45 rc=$?; echo "rc=$rc" >> $log 46 if (( rc == 124 )); then echo "HANG: $(tail -1 $done_)" >> $log; pkill -f "profile_$prof"; sleep 3 47 elif (( rc != 0 )); then echo "CRASH: $(tail -2 $done_ | head -1)" >> $log; exit 1; fi 48done 49pkill -f "profile_$prof" 50echo DONE >> $log 51