From e0a9f02224cdcf0e8e24616038aca905d31b60a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 21 Nov 2011 21:55:13 +0100 Subject: [PATCH] Fix `validate-target' in (system base target). * module/system/base/target.scm (validate-target): Accept any tuple with at least 3 parts. * test-suite/tests/asm-to-bytecode.test (test-triplet): New procedure. ("cross-compilation"): New test prefix. --- module/system/base/target.scm | 2 +- test-suite/tests/asm-to-bytecode.test | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/module/system/base/target.scm b/module/system/base/target.scm index 573ccca46..68c92d854 100644 --- a/module/system/base/target.scm +++ b/module/system/base/target.scm @@ -42,7 +42,7 @@ (define (validate-target target) (if (or (not (string? target)) (let ((parts (string-split target #\-))) - (or (< 3 (length parts)) + (or (< (length parts) 3) (or-map string-null? parts)))) (error "invalid target" target))) diff --git a/test-suite/tests/asm-to-bytecode.test b/test-suite/tests/asm-to-bytecode.test index 049e4b2fd..c2b9cce39 100644 --- a/test-suite/tests/asm-to-bytecode.test +++ b/test-suite/tests/asm-to-bytecode.test @@ -1,15 +1,17 @@ ;;;; Assembly to bytecode compilation -*- mode: scheme; coding: utf-8; -*- ;;;; +;;;; Copyright (C) 2010, 2011 Free Software Foundation, Inc. +;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public ;;;; License as published by the Free Software Foundation; either ;;;; version 3 of the License, or (at your option) any later version. -;;;; +;;;; ;;;; This library 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 ;;;; Lesser General Public License for more details. -;;;; +;;;; ;;;; You should have received a copy of the GNU Lesser General Public ;;;; License along with this library; if not, write to the Free Software ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -19,6 +21,7 @@ #:use-module ((rnrs io ports) #:select (open-bytevector-output-port)) #:use-module (test-suite lib) #:use-module (system vm instruction) + #:use-module (system base target) #:use-module (language assembly) #:use-module (language assembly compile-bytecode)) @@ -114,3 +117,23 @@ (uint32 0) ;; metalen make-int8 3 return)))) + + +(define (test-triplet cpu vendor os) + (let ((triplet (string-append cpu "-" vendor "-" os))) + (pass-if (format #f "triplet ~a" triplet) + (with-target triplet + (lambda () + (and (string=? (target-cpu) cpu) + (string=? (target-vendor) vendor) + (string=? (target-os) os))))))) + +(with-test-prefix "cross-compilation" + + (test-triplet "i586" "pc" "gnu0.3") + (test-triplet "x86_64" "unknown" "linux-gnu") + (test-triplet "x86_64" "unknown" "kfreebsd-gnu")) + +;; Local Variables: +;; eval: (put 'with-target 'scheme-indent-function 1) +;; End: